Thursday, January 20, 2011

Second Highest Salary

select min(sal) from emp where sal=(select sal from emp where sal<>MIN(SAL) )          
OR
from emp where sal=(select sal from emp having sal<>MIN(SAL)

select min(sal) from emp where sal>(select max(sal) from emp );

SELECT * FROM ( SELECT rownum n id salary FROM (select id salary from employees order by salary )) where n = 2 select min(sal) from emp where sal=(select sal from emp having sal<>MIN(SAL) )

SELECT min(sal) FROM emp WHERE sal > (SELECT Min(sal) FROM emp)

No comments:

Post a Comment