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
Does pl sql work in mysql?
What is blind sql injection?
What is execution plan in sql?
Is sqlite free?
Can we use ddl statements in stored procedure?
How to run pl/sql statements in sql*plus?
what is a database? : Sql dba
What is the difference between count 1 and count (*) in a sql query?
How to write a query to show the details of a student from students table whose
What does rownum mean in sql?
Which is better join or subquery?
Write a sql query to get the third highest salary of an employee from employee_table?
Explain what is sql?
How do I find duplicates in two columns?
Explain ttitle and btitle.