SQLTeam.com | Weblogs | Forums

How do I find the a value for the newest year?


I have a table that contains a Year, and AnnualPay, and a person's name.
How do I find the latest annual pay.

Select AnnualPay from MyTable where name='MyName' and
Year = max(Year) where name='MyName'

(That's probably not right be should show what I"m looking for.)


For a single year for one specific person:

Select TOP (1) * --list_of_cols...
from MyTable 
where name='MyName'
order by year desc