Nth max salary in Oracle

前端 未结 26 1721
名媛妹妹
名媛妹妹 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:42

    You can optimize the query using Dense_rank() function.

    for Example :

    select distinct salary from ( select salary ,dense_rank() over (order by salary desc) ranking from Employee ) where ranking = 6

    Note: ranking 6 is the number of nth order.

提交回复
热议问题