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 the difference between microsoft access and sql?
How can you know that statistics should be updated?
Can ddl statements be used in pl/sql?
How do you add a column to a table?
What are pl sql data types?
What is scalar function in sql?
What is rowtype?
What are pl/sql cursors?
Can a table have no primary key?
What is the difference between clustered and non-clustered index in sql?
Is it possible to pass parameters to triggers?
How many types of triggers exist in pl/sql?
What is over () in sql?
What is pl/sql table? Why is it used?
What is an index in sql with example?