GROUP BY and TOP

  • Thread starter Thread starter shank
  • Start date Start date
S

shank

In the following query, my results are grouped by year.
How can I change this query to give me the top 5 values for each year?
Is that possible, or do I have to make individual queries for each year?
thanks!

SELECT DataTable.Year, DataTable.OrderNo, DataTable.Qty, DataTable.Cost,
DataTable.SellPrice, DataTable.Description
FROM DataTable
GROUP BY DataTable.Year, DataTable.OrderNo, DataTable.Qty, DataTable.Cost,
DataTable.SellPrice, DataTable.Description, DataTable.SingleArtist
HAVING (((DataTable.SingleArtist)="Yes"))
ORDER BY DataTable.Year, DataTable.SellPrice DESC;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Top 3 per group 3
Top 5 3
Obtain Top Value from Table 9
Help with TOP 10 query please 4
Top Values Not Working 4
top n with duplicates 0
grouping quarters 3
top 20 records by group 5

Back
Top