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
Can we perform dml in function?
What is a temp table?
What do you mean by table in sql?
what are the different tables present in mysql? : Sql dba
how to include comments in sql statements? : Sql dba
discuss about myisam key cache. : Sql dba
List the ways to get the count of records in a table?
What does subquery mean in sql?
Why do we use function in pl sql?
How do I view a table in sql?
What are triggers and its types?
How do you declare a constant?
define sql delete statement ? : Sql dba
Should I use mbr or gpt?
What is restrict in sql?