Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning the maximum month for the maximum year

Status
Not open for further replies.

Robotron

Programmer
Mar 16, 2004
72
US
I have a table which has as 2 of it fields "Month" and "Year". What SQL statement would I use if I had the following data in order to return the maximum month for the maximum year.

MONTH YEAR
===== ====
7 2004
1 2005

If I select Max([Year]) and Max([Month]) together I get 2005 and 7.

Any help appreciated.

Robotron
 
Something like this ?
SELECT Max([Month]) As MaxMonth, [Year} As MaxYear
FROM yourTable
WHERE [Year]=(SELECT Max([Year]) FROM yourTable)
;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top