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 sqlerrm?
Can we rollback delete command?
What is the difference between sql, mysql and sql server?
discuss about myisam index statistics collection. : Sql dba
How to get unique records from a table?
What is pl sql block in dbms?
What is the largest value that can be stored in a byte data field?
Is sql low level language?
How do I write a sql query in pgadmin 4?
How do I find duplicates in sql?
What is right join in sql?
What is a design view?
How to display Row Number with Records in Oracle SQL Plus?
Is left join faster than join?
What is insert command in sql?