How to find the second highest salary from emp table?

December 28, 2009 | Filed Under MySQL | Comments Off

There are number of examples to get second highest salary from EMP table.

example-select sal from(select sal from
(select  distinct sal from emp order by sal desc)
where rownum<=2 order by sal asc)
where rownum=1;

example- SELECT MAX(SAL) FROM EMP WHERE SAL NOT IN (SELECT MAX(SAL)  FROM EMP)

where EMP is table name,SAL is salary colum.

Comments

Comments are closed.

© PHPInterviewQuestion.com 2009 - 2012

eXTReMe Tracker