Selecting limited rows

vtrm

Registered User.
Local time
Tomorrow, 02:07
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???????????
 
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
 
Thanks a bunch, Jeroen. It works perfect.
 

Users who are viewing this thread

Back
Top Bottom