(select count(1) from ehs_enterprise e where e.area_id = d.dict_value and e.create_time>= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' )) thisUnitNum,
(select count(1) from ehs_enterprise e where e.area_id = d.dict_value) totalUnitNum,
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) THEN 1 ELSE 0 END ) 'thisReportNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN 1 ELSE 0 END ) 'totalReportNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status = 10 THEN 1 ELSE 0 END ) 'thisHaveNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN 1 ELSE 0 END ) 'totalHaveNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status != 10 THEN 1 ELSE 0 END ) 'thisNotNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status != 10 THEN 1 ELSE 0 END ) 'totalNotNum',
CONCAT(round(ifnull(sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status = 10 THEN 1 ELSE 0 END )/sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) THEN 1 ELSE 0 END ),0)*100,2),'%') 'thisRate',
CONCAT(round(ifnull(sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN 1 ELSE 0 END )/sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN 1 ELSE 0 END ),0)*100,2),'%') 'totalRate'
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) THEN r.hd_count ELSE 0 END ) 'thisReportNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN r.hd_count ELSE 0 END ) 'totalReportNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status = 10 THEN r.hd_count ELSE 0 END ) 'thisHaveNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN r.hd_count ELSE 0 END ) 'totalHaveNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status != 10 THEN r.hd_count ELSE 0 END ) 'thisNotNum',
sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status != 10 THEN r.hd_count ELSE 0 END ) 'totalNotNum',
CONCAT(round(ifnull(sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) and r.status = 10 THEN r.hd_count ELSE 0 END )/sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.check_time >= DATE_FORMAT( now(), '%Y-%m-01 00:00:00' ) THEN r.hd_count ELSE 0 END ),0)*100,2),'%') 'thisRate',
CONCAT(round(ifnull(sum( CASE WHEN r.hidden_danger_id IS NOT NULL and r.status = 10 THEN r.hd_count ELSE 0 END )/sum( CASE WHEN r.hidden_danger_id IS NOT NULL THEN r.hd_count ELSE 0 END ),0)*100,2),'%') 'totalRate'
FROM
sys_dict_data d
LEFT JOIN ehs_hidden_danger r ON r.area_id = d.dict_value