SQL

K

Kirk P.

I've got the following data:

YearPrd YearMth
20043 2004-JAN
20044 2004-FEB
20045 2004-MAR
20046 2004-APR
20047 2004-MAY

I'm looking for a query that will return the MAX of YearPrd AND display the YearMth with it. In this case, the correct answer would be:

YearPrd YearMth
20047 2004-MAY

Any ideas?
 
J

John Spencer (MVP)

If that is exactly what you want to do then the following SAMPLE SQL should help
you achieve your goal.


SELECT YearPrd, YearMth
FROM YourTable
WHERE YearPrd =
(SELECT Max(YearPrd)
FROM YourTable)
 
Top