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

推荐订阅源

T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
量子位
有赞技术团队
有赞技术团队
阮一峰的网络日志
阮一峰的网络日志
The Cloudflare Blog
博客园 - Franky
罗磊的独立博客
宝玉的分享
宝玉的分享
博客园_首页
腾讯CDC
The GitHub Blog
The GitHub Blog
D
DataBreaches.Net
IT之家
IT之家
D
Docker
Microsoft Security Blog
Microsoft Security Blog
博客园 - 司徒正美
V
V2EX
月光博客
月光博客
N
Netflix TechBlog - Medium
爱范儿
爱范儿
I
InfoQ
P
Proofpoint News Feed

博客园 - 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(...
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