MAX records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a query which has the fields category, subcategory and description.
There are multiple exceptions per category, subcategory and description. I
want to pull out the top 3 descriptions per Category and Subcategory. How do
I do this?
 
Try something like

SELECT M1.category, M1.subcategory , M1.description
FROM TableName AS M1
WHERE M1.subcategory In (SELECT Top 3 M2.subcategory
FROM TableName as M2
WHERE M2.category =M1.category
ORDER BY M2.subcategory Desc)

Assuming that the subcategory field indicate the order the records were
inserted.
If not, then change the order by to include the field name that indicate the
order of thes records
 
Back
Top