Query for second maximum salary in each in each department

Answers were Sorted based on User's Feedback



Query for second maximum salary in each in each department..

Answer / jairam

select deptno,Max(e1.sal) from emp e1
where e1.sal NOT IN(select Max(e2.sal) from emp e2
group by e2.deptno)group by e1.deptno

Is This Answer Correct ?    0 Yes 3 No

Query for second maximum salary in each in each department..

Answer / nancy singhal

select max(salary) from emp where salary in(select salary
from emp where salary not in(select max(salary) from emp));

Is This Answer Correct ?    0 Yes 3 No

Query for second maximum salary in each in each department..

Answer / sravan

Select first_name, salary, rownum rank from
(select *from emp order by salary desc)

Is This Answer Correct ?    0 Yes 5 No

Query for second maximum salary in each in each department..

Answer / sampath pallerla

select distinct(a.sal) from emp a where 2=(select count(distinct(b.sal)) from emp b where a.sal<=b.sal);

Is This Answer Correct ?    1 Yes 7 No

Query for second maximum salary in each in each department..

Answer / yaswanth

select salary from(select salary,rownum rk from(select salary from employees order by salary desc)) ehere rk=2;

Is This Answer Correct ?    2 Yes 13 No

Post New Answer

More SQL PLSQL Interview Questions

How do you update a value in sql?

0 Answers  


why not null constraint showing its constraint type as 'c'

1 Answers  


Explain the purpose of %type and %rowtype data types?

0 Answers  


how to dump a table to a file with 'mysqldump'? : Sql dba

0 Answers  


Does view store data in sql?

0 Answers  






What is indexes?

0 Answers  


How to generate a salary slip like jan 1000 1000 feb 1000 2000 ... dec 1000 12000

0 Answers   BT,


Can we create view in stored procedure?

0 Answers  


Explain the difference between 'between' & 'and' operators in sql

0 Answers  


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

0 Answers  


What is Pragma EXECPTION_INIT ? Explain the usage ?

2 Answers  


What do you mean by table in sql?

0 Answers  


Categories