i need department wise top 2 employees salary.which logic
i will use
Answer Posted / nag
select distinct(sal), deptno from
(select * from emp a where 1 = (select count(distinct sal)+1
from emp b where b.sal > a.sal and b.deptno = a.deptno) and
deptno is not null
union
select * from emp a where 2 = (select count(distinct sal)+1
from emp b where b.sal > a.sal and b.deptno = a.deptno)and
deptno is not null)
order by deptno,sal
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Which join is like inner join?
What are sql constraints?
Explain spool.
What is sql basics?
Why select is used in sql?
What is transaction control language (tcl)?
Can there be 2 primary keys in a table?
What are the different sql commands?
What are the benefits of triggers?
How delete all data from all tables in sql?
What is union?
Is hadoop a nosql?
What is trigger and stored procedure in sql?
What is join view in sql?
how can you create an empty table from an existing table? : Sql dba