Selecting limited rows (1 Viewer)

vtrm

Registered User.
Local time
Today, 21:38
Joined
Jun 8, 2005
Messages
21
I have a table containing items and their prices. I need to run a SELECT Query which can return the last 5 prices for each item.

My Query is:
SELECT item, podate, price
FROM PurchaseOrders
GROUP BY item, podate, price
ORDER BY item, podate DESC, price

Let's say my Item A001 returned 12 records. I need only the 1st 5 records in my Report.

Can anybody help pls???????????
 
J

Jeroen

Guest
Hi, you can accomplish that by altering your statement to:

SELECT top 5 item, podate, price
FROM PurchaseOrders
GROUP BY item, podate, price
ORDER BY item, podate DESC, price
 

vtrm

Registered User.
Local time
Today, 21:38
Joined
Jun 8, 2005
Messages
21
Thanks a bunch, Jeroen. It works perfect.
 

Users who are viewing this thread

Top Bottom