如果MYSQL 表数据中含有0,则合为0,
select ruler from 表 where class='1',
现在需要查询ruler的总和,select sum(ruler) from 表 where class='1',
但如果 这些数据中有一个ruler等于0,则希望 sum(ruler)等于0,这样就能判断是不是有的ruler数据没有录入
SELECT CASE WHEN (SELECT COUNT(*) AS N FROM `表` WHERE RULER = 0 AND CLASS = 1) > 0 THEN 0 ELSE SUM(RULER) END AS RULER FROM `表` WHERE CLASS = 1