TO FIND THE SECOND HIGHEST SAL - Mysql Views : 351
Tagged in : Mysql
0 0
Send mail
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)
By Vijayaprasad, On - 2010-02-15



    Login to add Comments .