How to get second largest or third largest entry from a table

前端 未结 12 2502
说谎
说谎 2020-12-01 08:42

Can anyone please tell me how to find out the N th largest entry from a table in Oracle?

Like for largest we can use MAX(column_name) i

12条回答
  •  悲&欢浪女
    2020-12-01 09:19

    To get second largest salary use this:

    select salary from 
      (select s2.salary,rownum rm from
         (select distinct salary from employees order by salary desc)
      s2 where rownum<=2)
    where rm >= 2
    

提交回复
热议问题