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
Is ms sql traffic encrypted?
How do I start pl sql?
What is the use of count (*) in sql?
What are the features of pl sql?
What is materialized view in sql?
How do you truncate?
How long it takes to learn pl sql?
What is rownum?
How many sql are there?
How would you reference column values before and after you have inserted and deleted triggers?
Does sap use sql?
Which is faster view or stored procedure?
what is normalization? : Sql dba
What is a database trigger?
What is the difference between alter trigger and drop trigger statements?