Exclude latest record

K

KevinW

Hi,

Let's say I have a simple table with two fields. AutoID is a
AutoNumber, Details is text.

I have three records:

Record 1
AutoID: 1
City: Paris

Record 2
AutoID: 2
City: Madrid

Record 3
AutoID: 3
City: New York

If I want to create a query to select the last record I added, I can d
that: I simply select Top 1, and set AutoID to sort descending.

Here's what I can't do: create a query that returns everything *except
the last record I added. Is there some way I can exclude the las
record?

What I'm trying to say is 'not equals max[AutoID]' if that makes sense
I just can't find a way to say it!

Thanks,
Kevi
 
J

John Spencer (MVP)

SELECT AutoId, City
FROM Table
WHERE AutoID <>
(SELECT MAX(Tmp.AutoID)
FROM Table as Tmp)
 

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