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

What is analyze command used for?

575


How to revoke create session privilege from a user in oracle?

557


hey friends, What are the steps I can do to transfer the database from Microsoft Access 2003 to oracle10g (or SQL) Best regards

1562


What is oracle analytical function?

524


Explain the dml?

592






How to write a query with an inner join in oracle?

560


In the oracle version 9.3.0.5.0, what does each number shows?

748


Name the three major set of files on disk that compose a database in Oracle?

631


How to apply filtering criteria at group level in oracle?

584


What are the major difference between truncate and delete?

516


How to check your oracle database 10g xe installation?

579


How to get the Installed Oracle Version Information ?

622


Explain what are the uses of rollback segment?

582


Can a parameter be passed to a cursor?

600


Will you be able to store pictures in the database?

637