我有以下查询:
Select [Field], count([Field]) as Counts
from [Table_Name]
group by [Field]
结果如下所示:
[Field] [Counts]
Type1 100
Type2 100
Type3 100
Type4 100
Null 0
但是,当我依靠键或任何其他字段而不是我分组的字段时,我会得到 [Field] Null 的实际行数。这是为什么?
Select [Field], count([Other]) as Counts
from [Table_Name]
group by [Field]
结果:
[Field] [Counts]
Type1 100
Type2 100
Type3 100
Type4 100
Null 100