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 are the topics in pl sql?
How does stored procedure reduce network traffic?
How we can update the view?
How do I find duplicates in the same column?
Why cannot I use bind variables in ddl/scl statements in dynamic sql?
What is an oracle stored procedure?
How do you write an inner join query?
explain the difference between delete , truncate and drop commands? : Sql dba
Is id a reserved word in sql?
What is Materialized View? In What Scenario we Use Materialized View?
What is mutating table error?
What is right join sql?
what is the difference between sql and t-sql? : Transact sql
What is secondary key?
Is sql database free?