how to find the 2nd, 3rd ,4th ... nth highest salary of the employee from emp table?
select sal from emp e1 where (n-1)=(select count(DISTINCT sal)
from emp where sal > e1.sal )
Showing posts with label table. Show all posts
Showing posts with label table. Show all posts
Monday, June 16, 2008
Sunday, June 15, 2008
select second highest salary from emp table
1.select second highest salary from emp table
select max(sal ) from emp where sal<(select max
(sal)from emp)
select max(sal) from emp where level=2 connect by prior
sal>sal group by level;
2.select the employee details who is having the second highest salary from emp table
select A.* from emp A where 1=(select count(distinct
B.sal) from emp B where B.sal>A.sal)
3.select second highest salary of the employee along with first highest salary from emp table
select ename,sal from
(select ename,sal from emp
order by sal desc)
where rownum <=2;
select max(sal ) from emp where sal<(select max
(sal)from emp)
select max(sal) from emp where level=2 connect by prior
sal>sal group by level;
2.select the employee details who is having the second highest salary from emp table
select A.* from emp A where 1=(select count(distinct
B.sal) from emp B where B.sal>A.sal)
3.select second highest salary of the employee along with first highest salary from emp table
select ename,sal from
(select ename,sal from emp
order by sal desc)
where rownum <=2;
Subscribe to:
Posts (Atom)