Nth max salary in Oracle

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

    SELECT TOP (1) Salary FROM
    (
        SELECT DISTINCT TOP (10) Salary FROM Employee ORDER BY Salary DESC
    ) AS Emp ORDER BY Salary
    

    This is for 10th max salary, you can replace 10 with n.

提交回复
热议问题