惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
T
Threatpost
G
Google Developers Blog
T
Threat Research - Cisco Blogs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
The Exploit Database - CXSecurity.com
H
Heimdal Security Blog
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
Hacker News: Ask HN
Hacker News: Ask HN
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Schneier on Security
B
Blog
V2EX - 技术
V2EX - 技术
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
W
WeLiveSecurity
C
Cybersecurity and Infrastructure Security Agency CISA
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
Schneier on Security
Schneier on Security
F
Fortinet All Blogs
N
News | PayPal Newsroom
Attack and Defense Labs
Attack and Defense Labs
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
S
Security @ Cisco Blogs
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
Project Zero
Project Zero
I
Intezer
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
SecWiki News
SecWiki News
Martin Fowler
Martin Fowler

博客园 - 古道飘零客

Easyui combogrid添加toolbar SQL导出到Excel 存储过程 [WPF]DataGrid行前景色根据单元格编辑值变色 [转]系统性能调优吐血总结分享 [转]C#读取CSV,Excel,Txt文件,删除文件,拷贝文件 [转]C# 文件操作 全收录 追加、拷贝、删除、移动文件、创建目录、递归删除文件夹及文件.... JS四舍五入BUG解决 IIRF(Ionics Isapi Rewrite Filt er)实现在IIS 5/6上重写Url Repeater控件实现左侧快捷菜单 - 古道飘零客 - 博客园 JS和CS互访(非常经典) [转]IList及泛型集合类转换DataTable - 古道飘零客 - 博客园 关于sqlserver2005中的bit数据类型 C#小写转大写 - 古道飘零客 - 博客园 URL、Session、Cookies、Server.Transfer、Application和跨页面传送详解 sql server 2005 安装提示COM+ 和性能监视器计数器要求错误 [转cnblogs]网页静态 js如何判断小数点后有几位? - 古道飘零客 - 博客园 怎样读取本地Excel数据,并保存到时服务器 - 古道飘零客 - 博客园 C#项目打包,并自动安装SQL数据库 - 古道飘零客 - 博客园
oracle数据分组排名次
古道飘零客 · 2009-03-06 · via 博客园 - 古道飘零客

最近项目中遇到一个分组排名次的问题如下:

数据库里有如下一张表:
depart  A      B          C        Group

一支队    1      34.4      3.3        1
二支队    1      33.3      32.2        1
三支队    2      3.3      22.2        1
四支队    3.3    4.4      33.3        1
高新区    2.2    3.3      22.2        2
经开区    3.3    23        33.3        2
曲江区    4.5    35        23.9        2
未央区    12.2    39        3.3        2
长安区    30.3    23        2.2        2

我想用语句实现如下功能,用语句返回来的是如下一张表
depart  A      B          C        Group    总分    名次

二支队    1      33.3      32.2        1      66.5    1
四支队    3.3    4.4      33.3        1      41      2
一支队    1      34.4      3.3        1      38.7    3
三支队    2      3.3      22.2        1      27.5    4
曲江区    4.5    35        23.9        2      63.4    1
经开区    3.3    23        33.3        2      59.6    2
长安区    30.3    23        2.2        2      55.5    3
未央区    12.2    39        3.3        2      54.4    4
高新区    2.2    3.3      22.2        2      27.7    5

解决办法:
select *
from
(select a.*,nvl(a.b,0)+nvl(a.c,0) 总分
,row_number() over(partition by group order by nvl(a.b,0)+nvl(a.c,0)) 名次
from tb a
)
order by group,名次