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

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - Net205 Blog

我第1个可用的golang小程序 我们怎么做不到呢? Top 7 Coding Standards & Guideline Documents For C#/.NET Developers .Net开发人员必须避免的5个常见的编程错误 You are doing Scrum but the Scrum Master tells the team what to do! Asp.net Mvc中使用HTML 5 data属性 使用扩展方法 使用Javascript制作一个始终可见的区域 阅读优秀代码是提高开发人员修为的一种捷径[收藏] SQL Performance MSSQL删除重复数据 jQuery QUnit 万月薪的英语人是如何练成的!!!讲一口漂亮流利的英语[转] 博文阅读密码验证 - 博客园 博文阅读密码验证 - 博客园 asp.net Interview Questions - Net205 Blog jQuery资源 strip invalid xml characters - Net205 Blog 翻译工具,您选哪个?
SQL SERVER – Difference between COUNT(DISTINCT) vs COUNT(ALL)
Net205 Blog · 2011-03-09 · via 博客园 - Net205 Blog

http://blog.sqlauthority.com/2011/03/08/sql-server-difference-between-countdistinct-vs-countall/

COUNT(DISTINCT)和COUNT(ALL)的区别:前者像select distinct 字段1,字段2 from table一样会去掉重复的,后者则是统计字段的所有数据条数,与Count(字段1)相同。
COUNT(ALL)中的ALL实际上是缺省项,不需要指定。
(注:本人还有点怀疑COUNT(ALL)与COUNT(字段1)是否有区别,待验证)。

Here is the script:

1 SELECT COUNT([Title]) Value
2 FROM [AdventureWorks].[Person].[Contact]
3 GO
4 SELECT COUNT(ALL [Title]) ALLValue
5 FROM [AdventureWorks].[Person].[Contact]
6 GO
7 SELECT COUNT(DISTINCT [Title]) DistinctValue
8 FROM [AdventureWorks].[Person].[Contact]
9 GO


注:select count(字段1) from table,当字段1若有为null的记录,则此记录不在count结果内,要注意。

1 SELECT COUNT(*) FROM table
2 WHERE Column1 IS NULL.
3
4 select sum(any_null_data_count) from
5 (
6 select case when [any_null_data] is null then 1 else 0 end as any_null_data_count FROM [AdventureWorks].[Person].[Contact] where [any_null_data] is null
7 ) h1