Top three salaries [message #19733] |
Fri, 05 April 2002 01:36 |
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 |
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
|
|
|