select 厂房,count(*) 机器数量,sum(case when 状态='好' then 1 else 0 end) 新机器数量,sum(case when 是否检查过='是' then 1 else 0 end) 检察过的机器数量 from table1 group by 厂房