COUNT(*),count(1),COUNT(ALL expression),COUNT(DISTINCT expression) BY Group by
1 select column_2,count(column_2) as 'count(column_2)' ,count(column_1) as 'count(column_1)' ,count(*) as 'count(*)' 2 from dbo.T1 3 group by column_2
还是上次的数据源 http://www.cnblogs.com/SignalTips/p/4281751.html
这次是有group by的聚合
其实count(*)是最符合大众预期的。
最令人困惑是count(column_1),可以看到NULL值被记录了2次,而 1234则被记录1次。
count(column_2), NULL值被记录为0次,可以通过count(列名)排除NULL的定律