select sname,
(case num1 when 0 then 1 else 0 end ) +
(case num2 when 0 then 1 else 0 end ) +
(case num3 when 0 then 1 else 0 end ) +
...
(case numN when 0 then 1 else 0 end ) as 零的个数
select name,
case num1 when 0 then 1 else 0 end as a +
case num2 when 0 then 1 else 0 end as b +
case num3 when 0 then 1 else 0 end as c +
case num4 when 0 then 1 else 0 end as d as 等0的个数
from tb1
SELECT sname,
SUM(CASE num1 WHEN num1>0 THEN 1 END) AS num1,
SUM(CASE num2 WHEN num2>0 THEN 1 END) AS num2,
SUM(CASE num3 WHEN num3>0 THEN 1 END) AS num3,
SUM(CASE num4 WHEN num4>0 THEN 1 END) AS num4,
SUM(CASE num5 WHEN num5>0 THEN 1 END) AS num5
FROM T1
GROUP BY sname ...