5 last entries

  • Thread starter Thread starter Lars Rønning
  • Start date Start date
You can use the TOP predicate in SQL along with DESC (order by) to get what
you want.

SELECT TOP 5 * from MyTable ORDER BY SomeField DESC.

In the query builder, you can find TOP in the properties of the query,
 
Hi,

I want to display only the 5 last entries in my database, how can I set up a
query to fix this ? (Iæm running Access 2003

Access does not keep track of when your records were entered, and a
Table has no order - unless you have a timestamp field or a sequential
Autonumber, there is no way to do this. If you do, use a TOP VALUES
clause in your query and sort by the timestamp or the autonumber.
 
I do have a timestamp on each record. How do I sort i to just show the last
5 entires ?

Use the TOP VALUES property of the query:

SELECT TOP 5 <field>, <field>, <field>
FROM mytable
ORDER BY [timestamp];
 
Back
Top