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

推荐订阅源

L
LINUX DO - 最新话题
Cyberwarzone
Cyberwarzone
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Securelist
V2EX - 技术
V2EX - 技术
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy & Cybersecurity Law Blog
Spread Privacy
Spread Privacy
N
News and Events Feed by Topic
H
Heimdal Security Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
大猫的无限游戏
大猫的无限游戏
L
LangChain Blog
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
G
Google Developers Blog
Recorded Future
Recorded Future
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The GitHub Blog
The GitHub Blog
量子位
V
V2EX
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Vercel News
Vercel News
H
Help Net Security
Know Your Adversary
Know Your Adversary
Forbes - Security
Forbes - Security
T
Threatpost
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
T
Threat Research - Cisco Blogs
人人都是产品经理
人人都是产品经理
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
罗磊的独立博客
C
Check Point Blog
P
Palo Alto Networks Blog
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
L
LINUX DO - 热门话题
Apple Machine Learning Research
Apple Machine Learning Research
C
Cybersecurity and Infrastructure Security Agency CISA
A
Arctic Wolf

博客园 - antony.net

移动版网页自动缩放问题 2011年国内五款值得关注网店系统 Enterprise Architect 7 入门教程大全 Enterprise Architect 业务过程建模 不同浏览器处理后退的一些异同 - antony.net - 博客园 23个.NET开源项目 mysql 存储过程 游标 js代码库 table css 固定表头 - antony.net Hash Tables in Javascript 在非UI线程中改变UI控件属性的通用方法 RSClientPrint打印 文档格式批量转换(doc,txt,pdf等) 了解HTTP Headers的方方面面 XmlSerializer 常见问题疑难解答 webservices 水晶报表 - antony.net - 博客园 Build a Custom RadioButton Cell and Column for the DataGridView Control .NET 2.0 - WinForm Control - DataGridView 编程36计(二)
统计sql语句
antony.net · 2010-08-03 · via 博客园 - antony.net

--测试数据

DECLARE @t TABLE(ID int PRIMARY KEY,col decimal(10,2))

INSERT @t SELECT 1 ,26.21

UNION ALL SELECT 2 ,88.19

UNION ALL SELECT 3 , 4.21

UNION ALL SELECT 4 ,76.58

UNION ALL SELECT 5 ,58.06

UNION ALL SELECT 6 ,53.01

UNION ALL SELECT 7 ,18.55

UNION ALL SELECT 8 ,84.90

UNION ALL SELECT 9 ,95.60

--统计

SELECT a.Description,

Record_count=COUNT(b.ID),

[Percent]=CASE 

WHEN Counts=0 THEN '0.00%'

ELSE CAST(CAST(

COUNT(b.ID)*100./c.Counts

as decimal(10,2)) as varchar)+'%'

END

FROM(

SELECT sid=1,a=NULL,b=30  ,Description='<30' UNION ALL

SELECT sid=2,a=30  ,b=60  ,Description='>=30 and <60' UNION ALL

SELECT sid=3,a=60  ,b=75  ,Description='>=60 and <75' UNION ALL

SELECT sid=4,a=75  ,b=95  ,Description='>=75 and <95' UNION ALL

SELECT sid=5,a=95  ,b=NULL,Description='>=95' 

)a LEFT JOIN @t b 

ON (b.col<a.b OR a.b IS NULL)

AND(b.col>=a.a OR a.a IS NULL)

CROSS JOIN(

SELECT COUNTS=COUNT(*) FROM @t

)c

GROUP BY a.Description,a.sid,c.COUNTS

ORDER BY a.sid

/*--结果:

Description    Record_count  Percent

------------------- ------------------ ---------------------- 

<30          3            33.33%

>=30 and <60  2            22.22%

>=60 and <75  0            0.00%

>=75 and <95  3            33.33%

>=95         1            11.11%

--*/