Max function in a query

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
 
O

Ofer

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)
 
S

Steve Schapel

Alex,

Like this?...

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

Alex H

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
 
Top