Home » SQL & PL/SQL » SQL & PL/SQL » three maximum salary from each department?
three maximum salary from each department? [message #19802] Wed, 10 April 2002 12:04 Go to next message
dilshad
Messages: 2
Registered: April 2002
Junior Member
How can I get the maximum three salary from each department of the emp table?
Re: three maximum salary from each department? [message #19806 is a reply to message #19802] Wed, 10 April 2002 13:19 Go to previous message
Kutsal Berberoglu
Messages: 3
Registered: April 2002
Junior Member
Like this:
SELECT e_nm, e_dpt, e_salary
  FROM (SELECT   e_nm, e_dpt, e_salary,
                 RANK () OVER (PARTITION BY e_dpt ORDER BY e_dpt, e_salary DESC) AS RANK
            FROM emp
        ORDER BY e_dpt, e_salary DESC NULLS LAST)
 WHERE RANK < 4


Enjoy,

-Kutsal
Previous Topic: Compare times
Next Topic: DDL Trigger not firing -- Why??
Goto Forum:
  


Current Time: Wed Apr 24 04:18:40 CDT 2024