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
What do you mean by merge in oracle and how can you merge two tables?
How would you go about verifying the network name that the local_listener is currently using?
What is a user role in oracle?
How to store pictures on to the database?
What is the difference between I and G in Oracle?
What is a data lock in oracle?
How to use subqueries with the exists operator in oracle?
What is meant by joins?
What are oracle functions?
What are the common oracle dba tasks?
Use of an integrity constraint is better to validate data. Explain
Calculate difference between 2 date / times in oracle sql?
What is difference between sid and service name in oracle?
Please explain oracle left join with an example?
What is a subquery in oracle?