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 text? : Sql dba
What is clustered index in sql?
What pl/sql package consists of?
What plvcmt and plvrb does in pl/sql?
What are sql data types?
Is sql a backend language?
Is clustered index a primary key?
What is the usage of nvl function?
What is the use of <> sql?
Which is faster joins or subqueries?
what are numeric data types? : Sql dba
Why do we need view in sql?
What is data types in sql?
How to avoid using cursors?
What is varchar data type in sql?