Click here to Skip to main content
15,893,644 members
Please Sign up or sign in to vote.
1.44/5 (3 votes)
See more:
How to get n th max salary in sql server query , please suggest me simple query
Posted
Updated 25-Nov-16 21:52pm
Comments
André Kraak 18-Feb-14 5:01am    

DECLARE @COUNT INT

SELECT TOP 1 Salary FROM( SELECT TOP @COUNT DISTINCT Salary FROM EmployeeSalary ORDER BY Salary DESC ) Q ORDER BY Salary ASC
 
Share this answer
 
SQL
SELECT *from Employee_Test_salary

go

with emplsal as(
	SELECT Emp_Sal ,DENSE_RANK() over (order by Emp_Sal desc) as rownumber
	from Employee_Test_salary  
)
select top 1 Emp_Sal from emplsal where emplsal.rownumber =N
 
Share this answer
 
Comments
Patrice T 26-Nov-16 5:19am    
3 Years after answer was given ? Serious ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900