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 sql profiling in oracle?
what is a database? : Sql dba
What are the advantages of stored procedure?
Is sql free?
What is embedded sql with example?
what are the authentication modes in sql server? : Sql dba
How is data stored in sql?
What are conditional predicates?
What is substitution variable in pl sql?
How do I create an index in word?
How do I tune a sql query?
What is the plv (pl/vision) package offers?
What is bind variable in pl sql?
Explain mutating table error.
What is character functions?