By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,406 Members | 2,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,406 IT Pros & Developers. It's quick & easy.

Find last order date for each client

P: 2
Drawn a blank.

Looking to find the last date each client ordered something.

The query should show each client and the last order date.

2 tables: Clients and orders. clientID in each.

Any hints/directions appreciated. Even blistering attacks on my ability.

Thanks,

Jef
Nov 20 '06 #1
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Jef

We all have to start somewhere. The following query (using your field names of course) should do the job. This will return the clientID, name and last order date (assumes a valid date format for order date). Have a look and if there is anything you don't understand about how it works just ask.

Mary

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT Clients.ClientID, Clients.[ClientName], Max([OrderDate])
  3. FROM Clients INNER JOIN orders 
  4. ON Clients.ClientID=orders.ClientID
  5. GROUP BY Clients.ClientID, Clients.[ClientName];
  6.  
Nov 20 '06 #2

P: 2
Thanks Mary. I'll try this today.

Just found The Scripts yesterday. Looks good.

Jef
Nov 20 '06 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
Thanks Mary. I'll try this today.

Just found The Scripts yesterday. Looks good.

Jef
Thanks Jef

We're trying to build a community that's friendly to users at all levels. So never be afraid to ask basic questions.

All the experts who volunteer expect is that you post your questions clearly, following the Posting Guidelines ...

http://www.thescripts.com/forum/thread559246.html

and repsond with the results you obtained from their suggestions along with any variations you try.

If you put some work in yourself and respond clearly you'll get a lot of help here.

So far you've done good. Keep it up.

Mary
Nov 20 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.