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


Please Help Members By Posting Answers For Below Questions

What is sqlerrm?

553


Can we rollback delete command?

516


What is the difference between sql, mysql and sql server?

533


discuss about myisam index statistics collection. : Sql dba

531


How to get unique records from a table?

525






What is pl sql block in dbms?

532


What is the largest value that can be stored in a byte data field?

521


Is sql low level language?

580


How do I write a sql query in pgadmin 4?

558


How do I find duplicates in sql?

511


What is right join in sql?

558


What is a design view?

523


How to display Row Number with Records in Oracle SQL Plus?

594


Is left join faster than join?

549


What is insert command in sql?

530