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
What is scope and visibility in PL/SQL?
Is primary key is clustered index?
what is the difference between union and union all? : Sql dba
Why do we need view in sql?
What is pl sql commands?
What does the file extension accdb stand for?
Is it mandatory for the primary key to be given a value when a new record is inserted?
Explain the difference between 'between' & 'and' operators in sql
How to get help at the sql prompt?
What is anonymous block in sql?
What is the difference between Union and Union all. Which is faster.
What is hibernate and its relation to sql?
Why do we go for stored procedures?
What is rowid in sql?
how to check myisam tables for errors? : Sql dba