Deepak Verma
How to select the N<sup>th</sup> maximum salary from Table Emp in Oracle SQL Plus ?
By Deepak Verma in Databases & DBA on Mar 18 2011
  • Rob Murphy
    Mar, 2011 21

    a nice set based solution. replace the number '7' with whichever N is of interest

    select salary from Employees group by salary
    having salary =
    (select MIN(top_salary.list) from
        (select top 7 distinct_salaries.s as list from
            (select distinct salary as s from Employees
                group by salary) distinct_salaries
        order by distinct_salaries.s desc) top_salary
    )

    • 0
  • MAHESH MALLEPALLY
    Mar, 2011 21

    select * from emp

    where sal=(select max(sal) from emp

    where level=&level connect by prior sal>sal group bu level)

    • 0
  • Deepak Verma
    Mar, 2011 18

    SELECT Salary FROM
    (
    SELECT ROWNUM AS SN, Salary FROM
    (
    SELECT DISTINCT Salary FROM Emp ORDER BY Salary DESC
    )
    )
    WHERE SN = N;

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS