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
how to increment dates by 1 in mysql? : Sql dba
What is a natural join?
What is type and rowtype in pl sql?
Why coalesce is used in sql?
How do I send sql query results to excel?
how do you tune the slow running queries in oracle db , explain the methodology
Is natural join and inner join same?
Can a procedure in a package be overloaded?
How does sql*loader handles newline characters in a record? : aql loader
How can one get sql*loader to commit only at the end of the load file? : aql loader
What is the mutating table and constraining table?
What is nvl?
Can we join two tables without common column?
What are the most important ddl statements in sql?
How can I speed up sql query?