2 Records from query

  • Thread starter Thread starter Simon Ransom
  • Start date Start date
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
 
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
 
Back
Top