Home » SQL & PL/SQL » SQL & PL/SQL » Ranked Function in Oracle8.1.6
Ranked Function in Oracle8.1.6 [message #21543] Mon, 12 August 2002 01:07 Go to next message
Bhagwan Singh
Messages: 23
Registered: December 2001
Junior Member
hi,
using scott/tiger as login i have executed the following statement:

select deptno, sal, rank() over ( partition by deptno
order by sal desc) ranked_value from emp;

my output does not show rank 2 for deptno 20.How can I get the same?

Query Output:

DEPTNO SAL RANKED_VALUE
---------- ---------- ------------
10 5000 1
10 2450 2
10 1300 3
20 3000 1
20 3000 1
20 2975 3
20 1100 4
20 1000 5
30 2850 1
30 1600 2
30 1500 3
30 1250 4
30 1250 4
30 950 6

Desired Output:

DEPTNO SAL RANKED_VALUE
---------- ---------- ------------
10 5000 1
10 2450 2
10 1300 3
20 3000 1
20 3000 1
20 2975 2
20 1100 3
20 1000 4
30 2850 1
30 1600 2
30 1500 3
30 1250 4
30 1250 4
30 950 5

-Bhaggs
Re: Ranked Function in Oracle8.1.6 [message #21547 is a reply to message #21543] Mon, 12 August 2002 05:53 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
it is expeected.
inside dept 20,
first and second rank are shared by employees becuase they get the same sal.!!
Previous Topic: urgent
Next Topic: Update/Insert a Master Table
Goto Forum:
  


Current Time: Fri Apr 26 18:10:53 CDT 2024