TO FIND THE SECOND HIGHEST SAL
by Vijayaprasad[ Edit ] 2010-02-15 16:31:53
TO FIND THE SECOND HIGHEST SAL IN EMP TABLE
select max(sal) from emp where sal not in(select max(sal) from emp)
TO FIND THE 3RD HIGHEST SAL IN EMP TABLE
select max(sal) from emp where sal not in(select distinct top 2 sal from emp order by sal desc)
TO FIND THE Nth HIGHEST SAL IN EMP TABLE
select max(sal) from emp where sal not in(select distinct top N-1 sal from emp order by sal desc)