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 functions in sql?
What is synonyms?
what are the limitations of identity column? : Transact sql
Is postgresql a nosql database?
What is the use of function in sql?
Why is pl sql needed?
How much does sql certification cost?
What is an alias command?
How do I edit a stored procedure?
What does the argument [or replace] do?
What are the packages in pl sql?
What does stand for in sql?
What is output spooling in sql*plus?
Which join is like inner join?
how to select first 5 records from a table? : Sql dba