New Query

M

Maris

I would like to use a query to select the last 20 records
of a table. I can't find any way to limit the WHERE
clause of the query by a number of records. Any ideas?
TIA
 
D

Duane Hookom

You can set the TOP property of the query to 20. Make sure your query is
sorted so your 20 records appear first.
 
D

Dan Artuso

Hi,
Records in a table have no particular order, so in general,
the last 20 records has no meaning. You must have a field in the table
that will reliably indicate the last 20 records entered (if in fact that is what you mean
by 'the last 20 records'). For example, a DateEntered field would be good.

If you have such a field, then something like this would work:

Select TOP 20 DateEntered, otherfieldshere From yourTable
Order By DateEntered DESC

You might be able to get away with using an Auto-Number field, but it's not guaranteed
because they have been known to randomly go to negative numbers.
 
M

Maris

I have a date shipped field to use to sort the query by,
so TOP should work for what I want to do. Thanks much!!
 

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

Top