count不计算重复行

select vc_EmployeeName AS 姓名, 
count(distinct dt_ReceiveTime) AS [总计出差天数], 
count(distinct CASE vc_CustomerName WHEN '山西' THEN dt_ReceiveTime ELSE Null END) AS [山西] 
from SMS_DateReport 
where  dt_ReceiveTime >='2012/2/26 0:00:00' 
and dt_ReceiveTime <='2012/3/19 0:00:00' 
and vc_EmployeeName = '小王' and 1=1 group by vc_EmployeeName

你可能感兴趣的:(null,sms)