how to find the second highest salary from emp table?
Answer Posted / dsr
query:
======
select e.name,e.salary from emp e where &n =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)
after run enter n value:
if 2 enter second max salary will come
if 3 enter third max salary will come.
otherwise, we can write below
select e.name,e.salary from emp e where 2 =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what are the limitations of mysql in comparison of oracle? Mysql vs. Oracle. : Sql dba
What are keys in sql?
Explain lock escalation? : Transact sql
how to convert character strings to dates? : Sql dba
Can %notfound return null after a fetch?
What are the different set operators available in sql?
what is the bond code in materialized view?
What is a behavioral trigger?
Name three sql operations that perform a sort.
What are database links used for?
How many types of index are there?
Is sql between inclusive?
What is a natural join sql?
What does data normalization mean?
What does (+) mean in sql joins?