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

Is grant a ddl statement?

0 Answers  


What are the types of SQL Statement?

3 Answers  


Does sql*plus have a pl/sql engine?

0 Answers  


Does sql full backup truncate logs?

0 Answers  


What is Function based Index and which type of function we can use in Function base index. can we use aggregate,NVL function in Function based Index..

1 Answers   Metric Stream, Polaris,






Explain alias in sql?

0 Answers  


What is the difference between left join and left outer join?

1 Answers  


suppose we have values like 1 5 7 in a colum.Now we want numbers like(2 3 4 6) that exists between 1 5 7.How can we do this using sql query??

5 Answers   Keane India Ltd,


What is the difference between drop and truncate commands?

0 Answers  


Why do we use %rowtype & %type in plsql?

0 Answers  


What is posting?

0 Answers  


What is a pragma statement?

0 Answers  


Categories