Results 1 to 3 of 3

Thread: select distinct not working [moved]

  1. #1

    Thread Starter
    Addicted Member nyah_RMC's Avatar
    Join Date
    Jan 2002
    Location
    citadel
    Posts
    160

    select distinct not working [moved]

    i tried to run this statement but i got some errors...can someone show me how to do this correctly? i want to filter my employee records showing only the records with equivalent transactions on a given date...i mean i want to suppress my records displaying only those records with transactions that corresponds to a certain date... ??

    VB Code:
    1. Dim strGroupSQL As String
    2. Dim strDetailsSQL As String
    3. Dim strShapeSQL As String
    4. Dim cus As String
    5. Dim d As Date
    6.  
    7.    d = Date
    8.    strGroupSQL = "SELECT ID, Name FROM tblContact WHERE ID IN (SELECT DISTINCT tblTransaction.ID FROM tblTransaction)"
    9.    
    10.    strDetailsSQL = "SELECT tblContact.ID, tblContact.Name, tblTransaction.Total, tblTransaction.TransID, tblTransaction.Paid, tblTransaction.Total, "
    11.    strDetailsSQL = strDetailsSQL & "tblTransaction.Total - tblTransaction.Paid AS Balance ,tblTransaction.DueDate, tblTransaction.Settled "
    12.    strDetailsSQL = strDetailsSQL & "FROM tblContact INNER JOIN tblTransaction ON tblContact.ID = tblTransaction.ID WHERE tblTransaction.Settled LIKE 0 "
    13.    
    14.    strShapeSQL = "SHAPE {" & strGroupSQL & "} "
    15.    strShapeSQL = strShapeSQL & "APPEND ({" & strDetailsSQL & "} AS GrpDetails "
    16.    strShapeSQL = strShapeSQL & "RELATE ID to ID) "
    robee

    There's nothing wrong in asking, it proves only one thing. That you are Ignorant! but willing to dig on facts!

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: select distinct not working [moved]

    Originally posted by nyah_RMC
    i tried to run this statement but i got some errors...
    What errors?

    can someone show me how to do this correctly?
    i want to filter my employee records showing only the records with equivalent transactions on a given date...
    i mean i want to suppress my records displaying only those records with transactions that corresponds to a certain date... ??
    I cannot see any filters in the where clause for dates?
    Hint: Use hashes around the date.

    VB Code:
    1. Dim strGroupSQL As String
    2. Dim strDetailsSQL As String
    3. Dim strShapeSQL As String
    4. Dim cus As String
    5. Dim d As Date
    6.  
    7.    d = Date
    8.    strGroupSQL = "SELECT ID, [b][Name][/b] FROM tblContact WHERE ID IN (SELECT DISTINCT tblTransaction.ID FROM tblTransaction)"
    9.    
    10.    strDetailsSQL = "SELECT tblContact.ID, tblContact.[Name], tblTransaction.[Total], tblTransaction.TransID, tblTransaction.Paid, [i]tblTransaction.[Total][/i], "
    11.    strDetailsSQL = strDetailsSQL & "(tblTransaction.[Total] - tblTransaction.Paid) AS Balance ,tblTransaction.DueDate, tblTransaction.Settled "
    12.    strDetailsSQL = strDetailsSQL & "FROM tblContact INNER JOIN tblTransaction ON [i]tblContact.ID = tblTransaction.ID[/i] WHERE tblTransaction.Settled LIKE 0 "
    13.    
    14.    strShapeSQL = "SHAPE {" & strGroupSQL & "} "
    15.    strShapeSQL = strShapeSQL & "APPEND ({" & strDetailsSQL & "} AS GrpDetails "
    16.    strShapeSQL = strShapeSQL & "RELATE ID to ID) "
    The bit in bold may need square brackets (inserted) as Name is a function.
    The bit in italics (middle) looks like its a duplicate field?
    The bit in italics (bottom) is joining on the wrong id? Possibly?


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Addicted Member nyah_RMC's Avatar
    Join Date
    Jan 2002
    Location
    citadel
    Posts
    160
    ey sir i already filtered it...BUT my main problem is, records without transactions are still showing...how can i suppress it., showing only those with transactions on a given date??

    VB Code:
    1. strGroupSQL = "SELECT ID, Name FROM tblContact WHERE ID IN (SELECT DISTINCT tblTransaction.ID FROM tblTransaction)"
    2.    
    3.    strDetailsSQL = "SELECT tblContact.ID, tblContact.Name, tblTransaction.Total, tblTransaction.TransID, tblTransaction.Paid, tblTransaction.Total, "
    4.    strDetailsSQL = strDetailsSQL & "tblTransaction.Total - tblTransaction.Paid AS Balance ,tblTransaction.DueDate, tblTransaction.Settled "
    5.    strDetailsSQL = strDetailsSQL & "FROM tblContact INNER JOIN tblTransaction ON tblContact.ID = tblTransaction.ID WHERE tblTransaction.Settled = 0 AND tblTransaction.DueDate = #" & d & "#"
    robee

    There's nothing wrong in asking, it proves only one thing. That you are Ignorant! but willing to dig on facts!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width