Hi Friend here i am provide you MSsql query to find nth highest salary.
lots of example to find nth highest salary but here i am giving you a only two example.
1
SELECT * FROM emp Emp1 WHERE ( n ) = ( SELECT COUNT( DISTINCT ( Emp2.salary ) ) FROM emp Emp2 WHERE Emp2.salary >= Emp1.salary )
Select TOP 1 salary as '3rd Highest Salary' from (SELECT DISTINCT TOP 3 salary from emp ORDER BY salary DESC) a ORDER BY salary ASC
No comments:
Post a Comment