Need an access query to return both the oldest date and newest date from a related table

I need a query to return the oldest and newest sales record for each customer.  The data is stored in a SQL backend table.  There is a customer table (key-customerid) and a sales table (related field-customer id, record needed-DateReceived)
cmccurdyAsked:
Who is Participating?
 
Saurabh Singh TeotiaCommented:
You can do this to do what you are looking for...

select tb1.customerid,min(tb2.daterecieved) as firstsales,max(tb2.daterecieved) as lastsales
from customers tb1 
left join sales tb2 on tb1.customerid=tb2.customerid
group by tb1.customerid;

Open in new window


Saurabh...
0
 
cmccurdyAuthor Commented:
Perfect.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.