how to find the second highest salary from emp table?
Answer Posted / bharath reddy
These qeries give you second higest salary
select e.sal from emp e,emp d where d.sal>e.sal
group by e.sal
having count(e.sal)=2
;
SAL
-----
3000
(or)
select distinct e.sal from emp e where (select count(sal)
from emp d where d.sal>e.sal)=1;
SAL
-----
3000
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
how to create a new table in mysql? : Sql dba
How many sectors are in a partition?
What is memory optimized table?
What are the benefits of pl/sql packages?
What are different types of queries in sql?
What is the difference between microsoft access and sql?
How will you distinguish a global variable with a local variable in pl/sql?
How are functions and procedures called in PL/SQL?
Can we perform dml in function?
What is the difference between a query and a report?
What is right join sql?
Is sql a scripting language?
Why self join is used in sql?
What is the difference between joins?
How do I run pl sql in sql developer?