Just the record with the higest autonumber

S

Stu

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?
 
K

Ken Snell [MVP]

SELECT * FROM MyTable
WHERE MyAutoNumberField =
(SELECT Max(A.MyAutoNumberField)
FROM MyTable AS A);
 
S

Stu

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.
 
Top