在oracle中进行统计排序(跳跃排序和连续排序)

-- 在oracle中进行统计排序(跳跃排序和连续排序)
CREATE TABLE tb_score (
id number(11) NOT NULL PRIMARY KEY,
score number(11) DEFAULT NULL
) ;

select * from tb_score;

insert into tb_score select 1,87 from dual;
insert into tb_score select 2,87 from dual;
insert into tb_score select 3,97 from dual;
insert into tb_score select 4,67 from dual;
commit;

-- 跳跃排序,有并列名次的情况下,整个排序序号不连续
select id,score,
rank() over(order by score desc) as "rank"
from tb_score;

--连续排序,有并列名次的情况下,整个排序序号是连续
select id,score,
dense_rank() over( order by score desc) "rank"
from tb_score;

posted @ 2020-05-11 10:26  聚沙成塔  阅读(715)  评论(0编辑  收藏  举报