Return all records with maximum year, max -1 etc...

adamlaing

Registered User.
Local time
Today, 00:28
Joined
Jan 27, 2005
Messages
35
I need to build a query that will return 4 records starting with the maximum value in the year field then the next largest and so on. Basically I want the query to be: return the 4 records with the largest year fields (i.e. last four years). I have set the year as the primary key for my table. I'm not experienced with how to do this in the query builder - It appears that I need a select query with the table in question and the key part is in the criteria box for the year field, I just dont' know the syntax to enter the criteria.
 
Can you not sort on the year field (descending) and restrict the answer to 4 records? (Change the "All" in the toolbar to 4)

Col
 
Try:

SELECT top 4 Year
FROM YearTable
GROUP BY Year
ORDER BY Year DESC;
 

Users who are viewing this thread

Back
Top Bottom