Just the record with the higest autonumber

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

Guest

I have a very simple table with an autonumber field (total of 10 fields)
How do I write a query which returns only the record with the highest
autonumber in the entire table?
 
SELECT * FROM MyTable
WHERE MyAutoNumberField =
(SELECT Max(A.MyAutoNumberField)
FROM MyTable AS A);
 
Stu said:
I have a very simple table with an autonumber field (total of 10
fields) How do I write a query which returns only the record with the
highest autonumber in the entire table?

SELECT TOP 1 * FROM TableName ORDER BY AutoNumberFieldName DESC

In the query design grid open the property sheet and set "Top Values" to 1
and then make sure you apply a descending sort on the AutoNumber field.
 
That works - Thanks, Rick

Rick Brandt said:
SELECT TOP 1 * FROM TableName ORDER BY AutoNumberFieldName DESC

In the query design grid open the property sheet and set "Top Values" to 1
and then make sure you apply a descending sort on the AutoNumber field.
 
Back
Top