Home » SQL & PL/SQL » SQL & PL/SQL » Top three salaries
Top three salaries [message #19733] Fri, 05 April 2002 01:36 Go to next message
Ramana K.V.
Messages: 1
Registered: April 2002
Junior Member
Would you pl help me in getting the below SQL query solved!!!

The table is containing four columns empno,ename,sal
and deptno.

I want to display all the details of top 3 salary getting employees from each department.

Thank You.
Ramana K.V.
Re: Top three salaries [message #19735 is a reply to message #19733] Fri, 05 April 2002 01:53 Go to previous message
Dinesh
Messages: 31
Registered: October 2001
Member
hi,
If you are working on Oracle 8i or 9i database then you can use Dense_Rank() analytic function to get the desired result
look at this Query:

select ename,empno,salary,deptno,drank
from
(
select emp_name as ename, emp_no as empno,dept_no as deptno, basic_salary as salary ,dense_rank()
over ( partition by dept_no order by basic_salary desc ) as drank
from
employee
)
where drank < 4
This may solve your problem
Let me know if u still have any problems
Regards
Dinesh jv
Previous Topic: Apriori algorithm - Data Mining
Next Topic: How to store photos or gif images into database
Goto Forum:
  


Current Time: Thu Apr 25 18:19:47 CDT 2024