第一种方法:

select level as 威胁等级,count(id) as 个数 
from btzc_loo
where project_id = 396
and platform_status = 1
and company_status = 1
and company_repair_status = 2
group by level;

第二种方法:

SELECT
sum(IF( LEVEL = 4, 1, 0 )) AS '严重',
sum(IF( LEVEL = 3, 1, 0 )) AS '高危',
sum(IF( LEVEL = 2, 1, 0 )) AS '中危',
sum(IF( LEVEL = 1, 1, 0 )) AS '低危'
FROM
btzc_loo
WHERE
project_id = 396
AND platform_status = 1
AND company_status = 1
AND company_repair_status = 2;

第二种方法:

select
sum(case when level=4 then 1 end) as '严重',
sum(case when level=3 then 1 end) as '高危'
from btzc_loo
where project_id = 396
and platform_status = 1
and company_status = 1
and company_repair_status = 2