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 to use regular expression in pattern match conditions? : Sql dba
Which one is faster ienumerable or iqueryable?
explain advantages of innodb over myisam. : Sql dba
What is meant by cursor in sql?
What is scalar data type in pl sql?
What is application trigger?
What is difference between sql and oracle?
Is not equal in sql?
What are the two types of exceptions in pl/sql?
What is blind sql injection?
What is primary key secondary key alternate key candidate key?
What sql does db2 use?
What is an index in sql with example?
what is the difference between a web-garden and a web-farm? : Sql dba
How many types of cursors are available in pl/sql?