How to find the employee with the second highest salary?

前端 未结 5 2016
生来不讨喜
生来不讨喜 2020-12-02 01:10

Is there any predefined function or method available to get the second highest salary from an employee table?

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 01:30

    If you want to find the n highest salaries from the table, you can use this:

    select min(sal)from (select distinct sal from emp order by sal desc) where rownum<=n;
    

    where n is 1,2,3, ..., n

    It is a very easy process to find out the max salary from the table.

提交回复
热议问题