how to calcuate the second highest salary of he employee

Answers were Sorted based on User's Feedback



how to calcuate the second highest salary of he employee..

Answer / shailesh

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

Is This Answer Correct ?    0 Yes 1 No

how to calcuate the second highest salary of he employee..

Answer / jitendra

To get nth highest Salary, use below query

SELECT TOP 1 salary
FROM (
SELECT TOP nth salary
FROM Emp
ORDER BY salary DESC
) TmpTable
ORDER BY salary ASC

Replace nth with your number like second highest=2 4th=4 etc

Is This Answer Correct ?    0 Yes 3 No

how to calcuate the second highest salary of he employee..

Answer / vivek ghorad

select min(select top(2)salary from emp)from emp;

Is This Answer Correct ?    3 Yes 9 No

Post New Answer

More SQL PLSQL Interview Questions

how to see the oracle 9i/10g table in pc? or In my pc where the table is saved and how to see?

1 Answers  


what are myisam tables? : Sql dba

0 Answers  


i don't want the message as 14 rows updated just it should update what it will do

4 Answers  


hi,i plan to put experience on PLSQL ,can anyone suggest me for any institutes in bangalore or how to prepare for interviews

0 Answers  


How to make a copy values from one column to another in sql?

0 Answers  






Explain the commit statement.

0 Answers  


What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ?

2 Answers  


declare l1 number := null; l2 number :=null; begin if l1=l2 then message('equal'); else if l1<>l2 then message('not equal'); else message('else'); end if; end if; end; What will be the output ?

7 Answers   Oracle,


what is a relationship and what are they? : Sql dba

0 Answers  


function can return multiple value?how give give sample coding

2 Answers   3i Infotech, CTS, Excelity Global, UHG,


What are the rules to be applied to nulls whilst doing comparisons?

0 Answers  


Can we use view in stored procedure?

0 Answers  


Categories