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

推荐订阅源

Help Net Security
Help Net Security
G
Google Developers Blog
雷峰网
雷峰网
WordPress大学
WordPress大学
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Engineering at Meta
Engineering at Meta
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
AWS News Blog
AWS News Blog
F
Full Disclosure
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
J
Java Code Geeks
U
Unit 42
C
Cyber Attacks, Cyber Crime and Cyber Security
V
V2EX
C
Cisco Blogs
博客园 - 司徒正美
Project Zero
Project Zero
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
Scott Helme
Scott Helme
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog
S
Securelist
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
S
Schneier on Security
G
GRAHAM CLULEY
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyberwarzone
Cyberwarzone
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
T
Threatpost
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
The Register - Security
The Register - Security
S
Security Archives - TechRepublic
博客园 - Franky
N
News | PayPal Newsroom
Simon Willison's Weblog
Simon Willison's Weblog
S
SegmentFault 最新的问题
W
WeLiveSecurity
A
Arctic Wolf
B
Blog

博客园 - kkun

audit message types system_call specifies the system call by its name AUDIT SYSTEM REFERENCE ausyscall --dump NodeJS http 模块 NodeJS package.json NodeJS Hello world NodeJS 安装 透过 HoloLens,微软抢先看到了个人计算机的未来 [MSSQL2008]Spatial Data in SQL Server 2008 - 根据经纬度计算两点间距离 [MSSQL2005]再看CTE 博文阅读密码验证 - 博客园 博文阅读密码验证 - 博客园 [MSSQL2012]LEAD函数 [MSSQL2012]First_Value函数 [MSSQL]SQL疑难杂症实战记录-巧妙利用PARTITION分组排名递增特性解决合并连续相同数据行 [ALM]一步一步搭建MS ALM环境 - 安装TFS + SQL SERVER [ALM]一步一步搭建MS ALM环境 - 安装域服务器 [Hyper-V]制作一个干净的操作系统模板
[MSSQL2012]CUME_DIST函数
kkun · 2014-08-12 · via 博客园 - kkun

CUME_DIST函数以某列作为基准,计算其它行相对于基准行数据的比例、差距比例,比较容易理解

先看下测试数据

DECLARE @TestData TABLE(
    ID INT IDENTITY(1,1),
    Department VARCHAR(20),
    LastName VARCHAR(20),
    Rate FLOAT
)
INSERT INTO @TestData(Department,LastName,Rate)
SELECT 'Document Control','Arifin',17.7885 UNION ALL
SELECT 'Document Control','Norred',16.8269 UNION ALL
SELECT 'Document Control','Kharatishvili',16.8269 UNION ALL
SELECT 'Information Services','Chai',10.25 UNION ALL
SELECT 'Information Services','Berge',10.25 UNION ALL
SELECT 'Information Services','Trenary',50.4808 UNION ALL
SELECT 'Information Services','Conroy',39.6635 UNION ALL
SELECT 'Information Services','Ajenstat',38.4615 UNION ALL
SELECT 'Information Services','Wilson',38.4615 UNION ALL
SELECT 'Information Services','Connelly',32.4519 UNION ALL
SELECT 'Information Services','Meyyappan',32.4519

SELECT * FROM @TestData

CUME_DIST

第一个例子,代码比较简单,结果集里出来的一列Cume_Dist

image

第二个例子,与例1不同的是添加了分组,CUME_DIST被应用到每个组内,即每个组内有一个自己的基准,组内其它成员参照此基准进行运算

image

还有一个类似的函数,PERCENT_RANK,先猜猜这个函数做什么用?

------------------------------------------
除非特别声明,文章均为原创,版权与博客园共有,转载请保留出处
BUY ME COFFEE