Nth max salary in Oracle

前端 未结 26 1741
名媛妹妹
名媛妹妹 2020-11-30 07:02

To find out the Nth max sal in oracle i\'m using below query

SELECT DISTINCE sal 
FROM emp a 
WHERE (
       SELECT COUNT(DISTINCE sal) 
       FROM emp b 
          


        
26条回答
  •  孤街浪徒
    2020-11-30 07:52

    Try this one :

    Select sal 
    From (Select rownum as rank, empno,ename,sal
          From (Select * 
                From emp order by sal desc)
          ) 
    where rank=2;
    

    Just add the number as rank which will give you nth highest salary.

提交回复
热议问题