排名问题
来源:互联网 发布:西门子plc编程技巧 编辑:程序博客网 时间:2024/05/02 00:31
-- Create table
create table STUDENT
(
ID VARCHAR2(10),
XM VARCHAR2(10),
SCORE NUMBER(10)
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
select id, score, rn
from (select id, score, rank() over(order by score) rn from student )
where rn < 10 // 相同的名次不并列 跳过排名
id score rn
1 2 21 1
2 9 34 2
3 6 66 3
4 11 67 4
5 13 76 5
6 10 90 6
7 7 90 6
8 8 90 6
9 1 123 9
select id, score, rn
from (select id,
score,
dense_rank() over(/*partition by */ order by score) rn
from student)
where rn < 10 // 相同的名次并列 不跳过排名
id score rn
1 2 21 1
2 9 34 2
3 6 66 3
4 11 67 4
5 13 76 5
6 10 90 6
7 7 90 6
8 8 90 6
9 1 123 7
10 4 212 8
select *
from (select id,
score,
row_number() over(order by score desc) rn
from student)
where rn <= 10 // 不排名啊大哥 名次相同的不排名
id score rn
1 12 567 1
2 5 234 2
3 3 231 3
4 4 212 4
5 1 123 5
6 10 90 6
7 8 90 7
8 7 90 8
9 13 76 9
10 11 67 10
delete from student
where xm in
(select xm from student group by xm having count(xm) > 1)
and id not in
(select min(id) from student group by xm having count(xm) > 1) // 删除排名相同的人只留一个
rowid 的意义大家可以百度。
- 排名问题
- 排名问题
- 排名问题
- sql查询排名问题
- 四大湖排名问题
- 排名并列问题
- SQL语句--排名问题。
- 问题 A: 班级排名
- 球赛排名问题
- 简单的排名次问题
- 关于alexa排名问题说明
- oracle排名次的问题
- 关于排名问题的总结
- 针对对手排名下滑问题
- 网站相关性与排名问题
- Sql2000:处理排名中存在并列排名的问题
- 排名
- 排名
- 技术生涯新转折
- Cocos2d实现图标拖动和定位。
- C++ primer学习随记
- Java基础-网络编程(自定义图形界面浏览器-Tomcat服务端)
- HT全矢量化的图形组件设计
- 排名问题
- C++ primer(第五版) 练习 4.21 个人code
- linux 队列用法
- MFC多线程编程之四——线程的同步
- Java基础加强-eclipse开发工具
- windows OS右键-新建中添加C语言源文件
- bzoj1632 [Usaco2007 Feb]Lilypad Pond
- hdoj 1040 As Easy As A+B
- Java基础加强-JDK 5.0 新特性