how will I find the first 5 highest salaried employees in
each dept in oracle.

Answer Posted / murali mohan

Try This,

select empno,deptno,sal,dense_rank from (SELECT empno,
deptno,sal,
DENSE_RANK() OVER (PARTITION BY
deptno ORDER BY sal DESC NULLS
LAST) DENSE_RANK
FROM emp) tmp
where dense_rank<=5;

Regards,
Murali

Is This Answer Correct ?    21 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the use of grant option in imp command.

578


Explain the types of exception?

654


Briefly explain what is literal? Give an example where it can be used?

542


defination of bitmap index

1627


How to delete a column in an existing table?

593






How to start an oracle instance?

574


Is it possible to center an object horizontally in a repeating frame that has a variable horizontal size ?

1880


How many anonymous blocks can be defined?

586


How to export data to a csv file?

627


What are the advantages of oracle?

551


How to put more than 1000 values into an oracle in clause?

586


How to sort the query output in oracle?

610


What is the use of file param in imp command?

644


How to run the anonymous block again?

595


Explain the use of ignore option in imp command.

575