select...count()

declare @t table( c varchar(10));

insert @t
select *
from
(
 select 'A' as c union all
 select 'B' union all
 select 'B' union all
 select null union all
 select null
) t;

select count(*) from @t;
select count(c) from @t;
select count(distinct c) from @t;
select distinct c from @t;

测一下上面最后四条语句的执行结果: 

Code
原文地址:https://www.cnblogs.com/aspsmile/p/1402825.html