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;

No comments: