2 Records from query

S

Simon Ransom

** Remove the "simple_" to reply to me directly **

Hi all

I would like to know if/how i can return only the 2
latest records from a table. For example i have a field
that holds a create date/time. I would like my query to
only bring me the newest 2 records and no more.

Amy ideas/suggestions much appreciated.

Simon Ransom
 
T

Tom Ellison

Dear Simon:

You can write a subquery that finds the date/time values of these
rows:

SELECT TOP 2 CreateDateTime
FROM YourTable
ORDER BY CreateDateTime DESC

Then filter using an IN clause on this subquery

WHERE CreateDateTime IN
(SELECT TOP 2 CreateDateTime
FROM YourTable
ORDER BY CreateDateTime DESC)

** Remove the "simple_" to reply to me directly **

Hi all

I would like to know if/how i can return only the 2
latest records from a table. For example i have a field
that holds a create date/time. I would like my query to
only bring me the newest 2 records and no more.

Amy ideas/suggestions much appreciated.

Simon Ransom

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 

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