New Query

  • Thread starter Thread starter Maris
  • Start date Start date
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
 
You can set the TOP property of the query to 20. Make sure your query is
sorted so your 20 records appear first.
 
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.
 
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!!
 
Back
Top