Select only the last 10 occurance in a query of each Component No

  • Thread starter Thread starter jon
  • Start date Start date
J

jon

In a query I need to show only the last 10 of each component No in a
selected field.
The field has different component No:
Components have occurrences from 1 upwards.
I only want to see the last 10 of each component No in the field (or less
where less jobs have been made)
There is another date field in the table, and the table is grouped by
component No the sorted by date so I just need the last 10 of each component
No:

Advise please.

Thanks


Jon
 
Try this --
SELECT T.Product, T.YourDate, T.[component No], (SELECT COUNT(*)
FROM [jon] T1
WHERE T1.Product = T.Product
AND T1.[component No] >= T.[component No]) AS Rank
FROM jon AS T
WHERE ((((SELECT COUNT(*)
FROM [jon] T1
WHERE T1.Product = T.Product
AND T1.[component No] >= T.[component No]))<=10))
ORDER BY T.Product, T.[component No] 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

Back
Top