A common SQL Query
Posted by Nishanth Nair on April 11, 2008
This is a very simple SQL query for finding the 2nd highest salary from an employee table.
A very common question in .NET interviews. The query is pretty self explanatory.
select top(1)[Name],Salary from Employee
where salary not in (select top (1) salary from employee order by salary desc)
– Change the top parameter to (nth highest salary – 1)