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
Why do we use joins?
Which is faster count (*) or count 1?
What are packages in pl sql and also explain its advantages?
How to run sql functions in pl/sql?
How do you define a foreign key?
What is meaning of <> in sql?
Why do you partition data?
Is pl sql different from sql?
How to rename a column in the output of sql query?
What is the purpose of the sql select top clause?
What is the difference between mdf and ndf files?
Can unique keys be null?
How do you modify a table in sql?
How many parts of a pl sql block are optional?
How do I install microsoft sql?