统计某些状态总数sql
select
ne.plan_uuid as plan_uuid,
ne.checkunit_name as checkunit_name,
ne.checkunit_uuid as checkunit_uuid,
count(*) as total, --总数
sum(case
when detail.status>='200'
and detail.status<>'201' then 1
else 0
end) as pass ,--通过
sum(case
when detail.status='201' then 1
else 0
end) as unPass,--没通过
sum(case
when detail.check_ispass is null then 1
else 0
end) as unRecord--没到
from
nation_examineedetail detail,
nation_examineedate ne
where
detail.isdel<>1
and ne.isdel<>1
and detail.uuid=ne.detail_uuid
and ne.plan_uuid='cbaa6d10-68a6-4ac2-8932-dd87c00f16fd'
and ne.checkunit_uuid='cb6fa693-48db-4834-bcec-b948973f7ce2'
group by
ne.plan_uuid ,
ne.checkunit_name ,
ne.checkunit_uuid