Answered Questions

  • Find out nth highest salary from emp table

    SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal < = b.sal);For Eg:-Enter value for n: 2SAL---------3700

    Silpa

    • Apr 18th, 2018

    Select employee_id,salary, rownumber from (Select employee_id,salary,row_number() over (order by salary desc) as rownumber from hr.employees)
    where rownumber = n;

    VISHWA

    • Mar 10th, 2018

    Here for ROWNUM =1 it will work but for ROWNUM = 2 and so on it will not work.