Mysql CASE WHEN 用法
select
sum(1) as col_0_0_, sum(case vciinfo.useable when -1 then 1 else 0 end) as col_1_0_,
sum(case when vciinfo.activatetime is null then 0 else 1 end) as col_2_0_
from vci_info vciinfo
这是一个用case when 实现统计表中不同状态数据数量的sql语句
这里要注意的是 判断字段是否为空用 case when vciinfo.activatetime is null
判断值 case vciinfo.useable when -1
when 的位置不同