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

How to find the second highest salary?

EMPLOYEE table has fields EMP_ID and SALARY how do you find the second highest salary?

Best Answer
X
Best Answer - Chosen by Asker
Solution: We can write a sub-query to achieve the result SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN (SELECT MAX(SALARY) FROM EMPLOYEE) The first sub-query [SELECT MAX(SALARY) FROM EMPLOYEE] in the WHERE clause will return the MAX SALARY in the table and the main query SELECT’s the MAX SALARY from the results which doesn’t have the highest SALARY.
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
Comments
Order by: 
Per page:
 
  • There are no comments yet