home
training courses
why choose us?
solutions
support
company
LearnItFirst User Forum
Welcome Guest
Search
|
New Posts
|
Members
|
Log In
|
Register
SQL Server Forum - LearnItFirst.com
»
Transact-SQL Programming
»
DML (SELECT, INSERT, UPDATE, DELETE) Questions
»
How to get ID of the Max Date based on year
How to get ID of the Max Date based on year
Options
Previous Topic
·
Next Topic
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.
Back to top
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
)
Back to top
Users browsing this topic
Guest
Forum Jump
SQL Server Database Administration
- General SQL Database Question & Answer
- Backup, Recovery and Disaster Recovery
- SQL Server Security
- Integration Services (SSIS) and DTS
Transact-SQL Programming
- DML (SELECT, INSERT, UPDATE, DELETE) Questions
- Stored Procedures, Triggers, & Functions
SQL Server Scripts, Code Samples and SSMS Custom Reports
- All SQL Server Versions
- SQL Server 2005/2008
- SQL Server Management Studio Custom Reports
Customer Service
- Video Requests
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.
SQL Server 2005 DBA Training Videos
SQL Server 2008 DBA Training Videos
Email this topic
RSS Feed
Watch this topic
Print this topic
Normal
Threaded