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

Which are the five query types available in oracle?

528


What are privileges and grants?

571


What is SQL Tuning Advisor in Oracle?

633


How many types of auditing in Oracle?

566


Explain the use of indexes option in exp command.

590






What is the difference between formal parameters and actual parameters?

543


How to add a new column to an existing table with a default value?

543


Explain the use of record option in exp command.

533


How to loop through data rows in the implicit cursor?

539


What are the execution control statements in oracle?

600


A table t is there.If you perform insert ,update and delete then the trigger will fire.What is the minimum no of trigger required for a table.

4258


How to use "while" statements in oracle?

735


How to open and close an explicit cursor in oracle?

574


How to create a single index for multiple columns?

560


How to export your own schema?

570