标签:else char 求和 ase field 日期类型 case when case arc
例如以下情况,假如字段3是日期类型,按照小时分组统计字段1为空的个数,并对字段2大于5的值求和:
SELECT SUM(CASE WHEN field1 IS NULL THEN 1 ELSE 0 END) AS field1count,
SUM(CASE WHEN field2>5 then field2 else 0 end) AS field2sum
GROUP BY CONVERT(VARCHAR(13),field3,120)
标签:else char 求和 ase field 日期类型 case when case arc
原文地址:http://www.cnblogs.com/xueyuan299/p/6246112.html