Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query to retrive the most recent record

Author  Topic 

Vishnu Rajendran
Starting Member

1 Post

Posted - 2013-06-17 : 06:14:59
I have a 'emloyeeeducation' table where the education level of employees are captured.An employee can have many degrees like in BTech in 2007,MBA in 2011 .etc.My requirement is to show the 'Qualification' as the latest degree only,say here the qualification is MBA because it is the latest.It should be based on the year of passing.Please help me write the query.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-17 : 06:20:26
[code]
SELECT *
FROM
(
SELECT ROW_NUMBER() OVER (PARTITION BY employeeid ORDER BY yearofpassing DESC) AS Seq,*
FROM employeeducation
)t
WHERE Seq=1
[/code]

I've assumed columnnames based on your explanation so make sure you use correct columnnames instead if different from mine

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -