即条件求和,共三种方式 select sum(value = 'aaa') from test; select sum(if(value = 'aaa', 1, 0)) from test; select count(if(value = 'aaa', 1, null)) from test; 注意:使用count时if最后一个参数要写成null,写成0会统计失败