select top 3 sal from each dept?

Answer Posted / sambu

select r.sal,r.rank,r.dept high from
(select deptno,sal,dense_rank() over (partition by deptno
order by sal desc) rank
from emp) r
where r.rank=3;


The above query gives the following result

DEPTNO SAL HIGHEST
------ ----- -------
10 1300 3
20 1100 3
30 1500 3

Is This Answer Correct ?    3 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it possible to update views?

542


How many commands are in sql?

526


Can you do multiple joins in sql?

548


What is use of term?

626


What is the purpose of primary key?

533






What are the three pl sql block types?

573


what is the difference between char and varchar data types? : Sql dba

541


What is the difference between the conventional and direct path loads? : aql loader

695


How to disable a trigger name update_salary?

678


How do I view a view in sql?

508


Does truncate table reset auto increment?

528


Can we join same table in sql?

529


what are date and time functions in mysql? : Sql dba

536


what is the difference between cluster and non cluster index? : Sql dba

557


What is sql stand for?

577