Results 1 to 4 of 4

Thread: SQL statement needed

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    SQL statement needed

    I'm suffering from real brain fade at the moment and I just can't figure this out.

    We have 2 tables, customers and orders (one2many). What sql statement/s can I use to obtain the last order date for each customer

    It seems so simple but I'm going mad

    Thanks

  2. #2
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Code:
    Select DISTINCT(CustomerName), max(b.OrderDate) from Customer a
    Inner Join Orders b on b.CustomerID = a.CustomerID
    Group By a.CustomerName
    Order By a.CustomerName
    I think that should do it!
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    yeah!

    Thanks a lot man, you are a lifesaver!!


  4. #4
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Not a prob, I think we all have those days!
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


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