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 trigger price?
How do I view output in sql developer?
How do you add a column to a table?
Can we delete column in sql?
What is the use of index in sql?
Define overloaded procedure?
Why do we use subquery?
What action do you have to perform before retrieving data from the next result set of a stored procedure ?
What are the possible values for the boolean data field?
what is sub-query? : Transact sql
What is sql data?
Can I learn sql in a week?
Mention what is the use of function "module procedure" in pl/sql?
What is recursive stored procedure?
Can a foreign key be a duplicate?