dbTalk Databases Forums  

Find Earliest Order

comp.databases.ms-access comp.databases.ms-access


Discuss Find Earliest Order in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
TC
 
Posts: n/a

Default Re: Find Earliest Order - 07-29-2003 , 08:09 PM







"Susan" <smiller (AT) worthington (DOT) org> wrote


Quote:
I have a table with the fields, OrderID,CustomerID,OrderDate,...........
There
are multiple orders for most customers in this table. I need help
constructing a
query that returns the earliest order for each customer and the OrderID of
that
order.

Untested:

SELECT CustomerID, OrderID, OrderDate
FROM tblOrders AS a
WHERE OrderDate =
( SELECT min (OrderDate)
FROM tblOrders AS b
WHERE b.CustomerID = a.CustomerID )

But, understand that this could return *several* orders, each with the same
minimum date, for a single customer.

HTH,
TC






Reply With Quote
  #2  
Old   
Susan
 
Posts: n/a

Default Find Earliest Order - 07-29-2003 , 08:36 PM






I have a table with the fields, OrderID,CustomerID,OrderDate,........... There
are multiple orders for most customers in this table. I need help constructing a
query that returns the earliest order for each customer and the OrderID of that
order.

Thanks!

Susan



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.