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
What is the difference between a query and a report?
How do you declare a user-defined exception?
What is trigger price?
What is the unique index?
How do you update a value in sql?
Is it possible for a table to have more than one foreign key?
Can we call dml statement in function?
What is oracle and pl sql?
How do I write a cron which will run a sql query and mail the results to agroup?
Does mysql_real_escape_string prevent sql injection?
How to know the last executed procedure?
what are different types of collation sensitivity? : Sql dba
what are the advantages and disadvantages of views in a database? : Sql dba
Why plvtab is considered as the easiest way to access the pl/sql table?
Is natural join same as inner join?