Find out the 3rd highest salary?
Answer Posted / amit singh
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
RUN THE QUERY THEN ARG
amitsing2008@gmail.com(amit is back)
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How many types of sql are there?
How does cross join work?
How to display the current date in sql?
What is data manipulation language?
What is the maximum size of sqlite database?
Can we use rowid as primary key?
What does rownum mean in sql?
What does plv msg allows you to do?
Explain what is rdbms?
What is serial sql?
What is the difference between inner join and outer join?
How do you update a table in sql?
How many types of indexes are there in sql?
how to include numeric values in sql statements? : Sql dba
Is it possible to include an insert statement on the same table to which the trigger is assigned?