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
Explain what is an index?
Is sql a programming?
what is a field in a database ? : Sql dba
What is the current version of sql?
Why we use joins in sql?
i have 2 table table one 4 columns respective values a1 7,a2 6,a3 8 ,a4 12 & table two 4 colums respective values a1 7,a2 6,a3 8,a4 15.if table one & table two 3 colums same then 4th column values 1)Qes diff >5 then print 5 * diff value 2)Que diff <5 print 5
List and explain the different types of join clauses supported in ansi-standard sql?
How do you break a loop in pl sql?
how would you write a query to select all teams that won either 2, 4, 6 or 8 games? : Sql dba
Is pl sql and postgresql same?
what are all the different normalizations? : Sql dba
How run sql*plus commands that are stored in a local file?
how to run 'mysql' commands from a batch file? : Sql dba
What is pessimistic concurrency control? : Transact sql
How long does it take to learn pl sql?