Asked in Category :: Computers & Internet Software
SQL - Finding Nth Highest Salary

How to find the Nth highest salary from a table in SQL?

Best Answer
Best Answer - Chosen by Asker
Solution: Query to find the Nth highest salary: SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal) Replace &N in the above query with 2 if you want to know the second highest salary and so on.
Posted by merilturock on 06.05.2017 (06.05.2017)
0% 0 Votes
Rate this:


Other Answers
No other Answers posted.
Active Questions in this Category
No open Questions in this Category
Order by: 
Per page:
  • There are no comments yet