find out the third highest salary?

Answer Posted / amit singh

forget the book first
Empsal table data
700
500
100
900
400
200
600
750


query to find second highest salary from table Empsal

mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<(select max(salary) from Empsal));

Output=750



query to find third highest salary from table Empsal


mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<
>(select max(e1.salary) from Empsal e1
>where e1.salary IN(
>select e2.salary from Empsal e2 where
>e2.salary<(select max(salary) from Empsal))));
Output=700
don't args without run
amitsing2008@gmail.com(amy is back again)

Is This Answer Correct ?    3 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to define an oracle sub procedure?

603


what are archived logs?

1718


Where do we use decode and case statements?

564


How can I get column names from a table in oracle?

538


What is coalesce function?

577






Will you be able to store pictures in the database?

642


What is a cursor variable?

580


How to assign data of the deleted row to variables?

582


What is a database table in oracle?

574


What is oracle database 10g express edition?

603


How to write a query with a right outer join in oracle?

619


How to lock and unlock a user account in oracle?

618


How do you find current date and time in oracle?

590


Explain the use of record option in exp command.

539


What is instant client oracle?

544