Most efficient way to get 1000 most recent rows

G

Guest

I need a query to pull the most recent n rows from a table. I figure the most
efficient way must be to use the autonumber key since that is indexed. So I
need to get the highest key then all records prior to that up to a certain
number (say 1000).
How do I do that query (in SQL not the builder)?
 
J

Jeff Boyce

Access Autonumbers are not guaranteed to be sequential, and if, perchance,
they are set to (or become) random assignment, you are NOT likely to get the
"last" 1000 rows.

Is there a date/time field in the table definition? Use that to sort on,
and use the TOP property of the query to limit how many rows are returned.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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

Query most recent entry 2
Most Recent 7
Another most-recent date query 0
Most recent date 2
show the most recent payment 5
Most recent record 3
Exclude most recent record numbers 4
Query to pull most recent data 3

Top