1) Get N th highest salary

select emp, sal from(select emp, sal, rank() over (order by sal desc) rankSal from emp)where rankSal = n;

2) department wise top 2 employees salary
SELECT dept, MAX(sal) FROM EMP WHERE sal NOT IN GROUP BY dept) GROUP BY dept UNION SELECT dept, MAX(sal) FROM EMP GROUP BY dept (SELECT MAX(sal) FROM emp

How to find the Top sal ?
Select * from EMP where sal= (select max (sal) from EMP);

How to find 2 nd highest Sal ?
Select empno, ename, sal, r from (select empno, ename, sal, dense_rank () over (order by sal desc) r from EMP) where r=2;

How to find Top 5 salaries ?
Select empno, ename, sal,r from (select empno,ename,sal,dense_rank() over (order by sal OR Select * from (select * from EMP order by sal desc) where rownum<=5; desc) r from emp) where r<=5;

How to find the Dense rank ?
The DENSE_RANK function works acts like the RANK function except that it assigns consecutive ranks: Select empno, ename, Sal, from (select empno, ename, sal, dense_rank () over (order by sal desc) r from emp);

sal and a. How to remove duplicates in the table ? Delete from EMP where rowid not in (select max (rowid) from EMP group by empno). b. sal. b.deptno From EMP a. r from (select empno. deptno from EMP group by deptno) b Where a. (Select max (sal) sal.empno. ename.sal.A query to assign the Ranks Select empno. ename. How to get duplicate rows from the table ? Select empno.deptno=b. sal. rank () over (order by sal desc) r from EMP).sal=b. How Can we Get dept wise max sal along with empname and emp no ? Select a.deptno . a.empname. count (*) from EMP group by empno having count (*)>1.

Sign up to vote on this title
UsefulNot useful