Max function in a query

  • Thread starter Thread starter Alex H
  • Start date Start date
A

Alex H

Hi
i have a table which contains a list of dates. I can use the Max function
to obtain the most recent date, but I also need to obtain the second most
recent date - is this possible please?

Thanks

Alex
 
You can use this query, getting the max of date after filtering on the max of
date

SELECT Max(MyDateField) AS MaxDateField
FROM MyTable
WHERE MyDateField Not In (SELECT Max(MyDateField) AS MaxMyDateField
FROM MyTable)
 
Alex,

Like this?...

SELECT TOP 2 [YourDateField]
FROM YourTable
ORDER BY [YourDateField] DESC
 
Thanks - thats great - why do I always think it would be far more
complicated !

Alex

Steve Schapel said:
Alex,

Like this?...

SELECT TOP 2 [YourDateField]
FROM YourTable
ORDER BY [YourDateField] DESC

--
Steve Schapel, Microsoft Access MVP


Alex said:
Hi
i have a table which contains a list of dates. I can use the Max
function to obtain the most recent date, but I also need to obtain the
second most recent date - is this possible please?

Thanks

Alex
 

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

Back
Top