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

后端 未结 18 1268
孤城傲影
孤城傲影 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 17:35

    You should use something like this:

    SELECT *
    FROM (select salary2.*, rownum rnum from
             (select * from salary ORDER BY salary_amount DESC) salary2
      where rownum <= 2 )
    WHERE rnum >= 2;
    

提交回复
热议问题