i need department wise top 2 employees salary.which logic
i will use
Answer Posted / neo
select t1.empno, deptno, sal from emp t1 where t1.sal =
(select max(t2.sal) from emp t2 where t1.deptno = t2.deptno
group by deptno)
union
select t1.empno, deptno, sal from emp t1 where t1.sal =
(select max(t2.sal) from emp t2
where t2.sal < (select max(t3.sal) from emp t3 where
t3.deptno = t2.deptno and t1.deptno = t2.deptno )
group by deptno)
order by deptno, sal desc;
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is cursor and its types?
What are the different types of a subquery?
How is sql used in oracle?
How to get list of all tables from a database?
What is cross join example?
mention if it is possible to import data directly from t-sql commands without using sql server integration services? If yes, what are the commands? : Transact sql
What is difference between sql and excel?
Why do we need cursor in pl sql?
what is sql? : Sql dba
What is sql deadlock?
How do you break a loop in pl sql?
What are few of the schema objects that are created using PL/SQL?
What is the difference between inner join and left join?
What is the use of pl/sql table?
What is record variable?