Thursday, June 6, 2013

Finding the 3rd highest salary of an employee. (SQL)

Question


From the employee table, find the employee who earns the 3rd highest salary.



Solution

SELECT TOP 1 * FROM dbo.emp E
WHERE E.Salary IN
(SELECT TOP 3 Salary FROM dbo.emp
ORDER BY Salary desc)
ORDER BY E.Salary asc


 

No comments: