-
Analytical Function
Hello Masters;
I have confusion. I have gone through many documnetation but still not clear how the ranks are decided.
In the following code. How eight is given rank as 1, not nine, same as five is given rank two instead of seven. So i would like to know how this ranks are decide. i know the densed rank keep the sequence even though the tie in th data.
Code:
create table top_n_test (
a number,
b varchar2(10)
);
insert into top_n_test values (1, 'one');
insert into top_n_test values (2, 'two');
insert into top_n_test values (3, 'three');
insert into top_n_test values (4, 'four');
insert into top_n_test values (5, 'five');
insert into top_n_test values (6, 'six');
insert into top_n_test values (7, 'seven');
insert into top_n_test values (8, 'eight');
insert into top_n_test values (9, 'nine');
commit;
Code:
select
a,b,
dense_rank() over (order by b) RD,rank() over (order by b) R
from
top_n_test;
result
Code:
A B RD R
8 eight 1 1
5 five 2 2
4 four 3 3
9 nine 4 4
1 one 5 5
7 seven 6 6
6 six 7 7
3 three 8 8
2 two 9 9
-
The rank is based on the alphabetical order of the column of number names.
-
Thank you so much for your help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|