我使用的是甲骨文Apex,我是排名呼叫速度。我几乎要得到我想要的结果了。我面临的唯一问题是,当秩函数遇到重复值时,默认情况下,它们都被分配到最低等级。例如:
Rank Call Speed
1 65
2 72
3 92
4 102
4 102
4 102
4 102
4 102
9 113
10 154
11 201
12 352是否有4's表示为8's (重复的最高等级)?
一种方法是使用排序降序,然后从最高级别+ 1中减去这个值,这是可行的,但似乎是一个不必要的步骤。
任何帮助都将不胜感激。
发布于 2013-12-13 20:07:14
做这件事有点奇怪,但我会这样做:
with data as (
select 65 call_speed from dual union all
select 72 call_speed from dual union all
select 92 call_speed from dual union all
select 102 call_speed from dual connect by level <= 5 union all
select 113 call_speed from dual union all
select 154 call_speed from dual union all
select 201 call_speed from dual union all
select 352 call_speed from dual
)
select
rank() over (order by call_speed) + count(*) over (partition by call_speed) - 1 rank,
call_speed
from data;这给了你:
RANK CALL_SPEED
---------- ----------
1 65
2 72
3 92
8 102
8 102
8 102
8 102
8 102
9 113
10 154
11 201
12 352发布于 2013-12-17 05:58:47
只是一个选择,没有任何理由,除了可能避免任何内存开销(?)进行分区计数:
with data as (
select 65 call_speed from dual union all
select 72 call_speed from dual union all
select 92 call_speed from dual union all
select 102 call_speed from dual connect by level <= 5 union all
select 113 call_speed from dual union all
select 154 call_speed from dual union all
select 201 call_speed from dual union all
select 352 call_speed from dual
)
select
count(*) over () + 1 - rank() over (order by call_speed desc) rank,
call_speed
from data
order by call_speed;https://stackoverflow.com/questions/20573947
复制相似问题