select
count( case when status='1' then number1 end) as '检查不及格',
count(case when status='2' then number1 end) as '终止作废',
sum( case when status='3' then number2 end) as '遗失作废'
from table1
select
count( case when status='1' then number1 end) as '检查不及格',
count(case when status='2' then number1 end) as '终止作废',
sum( case when status='3' then number2 end) as '遗失作废'
from table1
转载于:https://www.cnblogs.com/kevin2013/archive/2011/01/21/1941495.html