Quote:
Originally Posted by lavanya
I am not sure but it will definitely work just try once.
[sql]( select salary from <tablename> where sal <(select salary from <tablename> where sal <(select max(sal) from <tablename>))) [/sql]
This will give the third highest salary from a table.
And for the second highest salary just remove one phrase that is
[sql]select salary from <tablename> where salary<(select max(salary) from <tablename>)[/sql]
|
[sql]select salary from <tablename> where salary<(select max(salary) from <tablename> wont work for second highest salary.[/sql]
The correct query is
[sql]select max(salary) from <tablename> where salary<(select max(salary) from <tablename>[/sql]
to get the third highest salary :
[sql]( select max(salary) from <tablename> where sal <(select max(salary) from <tablename> where sal <(select max(sal) from <tablename>)))[/sql]