Query to find nth highest salary or Second highest salary in SQL Server
Select * from Employee
select Max(salary) from Employee where Salary (select Max(Salary) from Employee)
=========================================================================
WITH RESULT AS
(
Select Salary , DENSE_RANK() over (Order By Salary DESC) as DENSERANK from employee
)
Select top 1 Salary From RESULT where DENSERANK = 2
you can change your DENSERANK value accordingly in where condition
=========================================================================
you can change your DENSERANK value accordingly in where condition
=========================================================================
Select TOP 1 Salary From (select TOP 2 Salary fromemployee order BySalary Desc)Result Order bySalary