Limiting results in a query

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

Guest

Can anyone tell me how i can limit the results from a query to the last 5
records per field. for example, i have a comments table that has comments
field and a link field for the record it links too. how would i run a query
so that only the last 5 comments appear per link field?

thanks
 
You can add TOP 5 to the SQL statement but there must be a field that is
sorted DESC so as to know what comes first or last. If the comments table
have an autonumber field or DateTime field then you are in like Flint.

SELECT TOP 5 YourTable.YourFirstField, YourTable.YourNextField, etc...;
 

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