How can I select the record with the 2nd highest salary in database Oracle?

后端 未结 18 1430
孤城傲影
孤城傲影 2020-12-30 17:27

Suppose I have a table employee with id, user_name, salary. How can I select the record with the 2nd highest salary in Oracle?

I googled it, find this solution, is t

18条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-30 18:01

    This query works in SQL*PLUS to find out the 2nd Highest Salary -

    SELECT * FROM EMP
    WHERE SAL = (SELECT MAX(SAL) FROM EMP
    WHERE SAL < (SELECT MAX(SAL) FROM EMP));
    

    This is double sub-query.

    I hope this helps you..

提交回复
热议问题