LearnItFirst User Forum

SQL Server 2008 SSAS Training Videos
Welcome Guest Search | New Posts | Members | Log In | Register

How to get ID of the Max Date based on year Options
sreeni2219
Posted: Wednesday, April 14, 2010 10:05:17 AM
Rank: Newbie

Joined: 4/14/2010
Posts: 1
Points: 3
Where do you live?: USA
I have a Table with the below structure.
ID SurveyDate FY
100 8/25/2009 2009
200 8/26/2009 2009
300 8/29/2009 2009
400 9/1/2010 2010
500 9/30/2010 2010
i want ID for each Year MaxDate. How to get that easily? I need ID only Because this ID i want to use as part of the Subquery.
Scott Whigham
Posted: Wednesday, April 14, 2010 12:17:16 PM


Rank: Super Mod

Joined: 3/20/2006
Posts: 476
Points: 1,053
Where do you live?: Dallas, TX
SELECT ID
FROM MyTable
WHERE SurveyDate = (
SELECT MAX(SurveyDate)
FROM MyTable
)
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.