Selecting the most reent order

crisp

Registered User.
Local time
Today, 04:07
Joined
Jan 19, 2004
Messages
23
Selecting the most reent order SOLVED

I have a database with 2 tables, one for stoing order numbers and the date and time that order was placed, and another for each of the items in that order.

I want to create a query to select only the most recent order and show all of the items in that order.

Orders table:

OrderNumber, OrderDate, OrderTime
134661466, 12/12/04, 12:56:33
235626555, 13/12/04, 14:12:27
723544533, 13/12/04, 17:44:58

Items table:

OrderNumber, ItemNumber, ItemDescription
134661466, 1, something
134661466, 2, something else
134661466, 3, yet another something
723544533, 4, and another

Thanks for any help anyone can give,
Chris
 
Last edited:
here you go ;)

select *
from orders o inner join items i on i.ordernumber = o.ordernumber
where o.ordernumber = (select max(ordernumber) from orders)



or

select top1 *
from orders o inner join items i on i.ordernumber = o.ordernumber
order by ordernumber desc
 
YAY Thanks it works brilliant
 

Users who are viewing this thread

Back
Top Bottom