select top 3 sal from each dept?

Answer Posted / venkateswara thiruvedhula

SELECT empno,
deptno,
sal,
RANK() OVER (PARTITION BY deptno ORDER BY sal
desc) "rank"
FROM emp;

EMPNO DEPTNO SAL rank
---------- ---------- ---------- ----------
7934 10 5000 1
7782 10 3000 2
7839 10 2000 3
7369 20 2950 1
7876 20 1700 2
7566 20 1100 3
7788 20 900 4
7902 20 900 4

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between triggers and constraints?

521


How does sql developer connect to oracle database?

524


How do I find duplicates in the same column?

547


What is the difference between sql and isql*plus?

515


What is pl/sql language case sensitive?

635






How are sql commands classified?

595


How do you modify a trigger?

526


what is the difference between mysql_fetch_array and mysql_fetch_object? : Sql dba

558


What is pl sql block in dbms?

528


How to order siblings in oracle hierarchy queries?

600


What steps server process has to take to execute an update statement?

511


Is sqlexception checked or unchecked?

541


Explain character-manipulation functions?

636


Is sql harder than python?

612


What is union and union all keyword in sql?

568