How to get second highest salary from a table

Answers were Sorted based on User's Feedback



How to get second highest salary from a table..

Answer / senthil

select max(sal) from emp where sal <(select max(sal) from emp)

Is This Answer Correct ?    13 Yes 1 No

How to get second highest salary from a table..

Answer / srinivas

select * from emp m where(select count(distinct sal)+1 from emp s where s.sal>m.sal)=2

Is This Answer Correct ?    7 Yes 3 No

How to get second highest salary from a table..

Answer / saiz

select min(salary)
from emp
where salary in ( select top 2 salary
from emp
order by salary desc);

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Why are sql stored procedures used?

0 Answers  


can we write stored function in out parameters? how to call through select statement? how to written more than one value plz give the exmple?

1 Answers  


what is the use of anchoring object? what r the difference between anchoring object & enclosing object? can any one tell me all the details?

0 Answers  


What are the steps you take to tune(performance tuning) the code in plsql?

4 Answers   Cap Gemini, Infosys, TCS,


What is out parameter used for eventhough return statement can also be used in pl/sql?

0 Answers  






I have 2 packages A and B. Now package A references Package B and Package B references Package A. How do you compile such inter-dependent objects in PL/SQL

5 Answers   Doyensys, Infosys, Metric Stream,


Can a foreign key have a different name?

0 Answers  


what are the differences between public, private, protected, static, transient, final and volatile? : Sql dba

0 Answers  


What is substitution variable in pl sql?

0 Answers  


How can we avoid duplicating records in a query?

0 Answers  


How to combine two stored procedures in sql?

0 Answers  


Can we update views in sql?

0 Answers  


Categories