一、查询SQL
SELECTt1.规则编号 AS 编码,t1.规则描述 AS 名称,SUM( CASE WHEN t3.DATA_SOURCES = '00' THEN 1 ELSE 0 END ) AS '类型01',SUM( CASE WHEN t3.DATA_SOURCES = '01' THEN 1 ELSE 0 END ) AS '类型02',SUM( CASE WHEN t3.DATA_SOURCES = '02' THEN 1 ELSE 0 END ) AS '类型03',SUM( CASE WHEN t3.DATA_SOURCES = '03' THEN 1 ELSE 0 END ) AS '类型04' FROM( SELECT'A_M_0001' AS 规则编号,'规则01' AS 规则描述 UNION ALL SELECT'A_M_0002' AS 规则编号,'规则02' AS 规则描述 UNION ALL SELECT'A_M_0003' AS 规则编号,'规则03' AS 规则描述 UNION ALL SELECT'A_M_0005' AS 规则编号,'规则04' AS 规则描述 UNION ALL SELECT'A_M_0007' AS 规则编号,'规则05' AS 规则描述 UNION ALL SELECT'A_M_0006' AS 规则编号,'规则06' AS 规则描述 UNION ALL SELECT'A_M_0008' AS 规则编号,'规则07' AS 规则描述 UNION ALL SELECT'A_J_0001_01' AS 规则编号,'规则08' AS 规则描述 UNION ALL SELECT'A_J_0001_12' AS 规则编号,'规则09' AS 规则描述 UNION ALL SELECT'A_J_0001_02' AS 规则编号,'规则10' AS 规则描述 UNION ALL SELECT'A_J_0001_03' AS 规则编号,'规则11' AS 规则描述 UNION ALL SELECT'A_J_0001_13' AS 规则编号,'规则12' AS 规则描述 UNION ALL SELECT'A_J_0001_05' AS 规则编号,'规则13' AS 规则描述 UNION ALL SELECT'A_J_0001_11' AS 规则编号,'规则14' AS 规则描述 UNION ALL SELECT'A_J_0001_06' AS 规则编号,'规则15' AS 规则描述 UNION ALL SELECT'A_J_0001_14' AS 规则编号,'规则16' AS 规则描述 UNION ALL SELECT'A_J_0001_07' AS 规则编号,'规则17' AS 规则描述 UNION ALL SELECT'A_J_0001_15' AS 规则编号,'规则18' AS 规则描述 UNION ALL SELECT'A_J_0002_01' AS 规则编号,'规则19' AS 规则描述 UNION ALL SELECT'A_J_0002_02' AS 规则编号,'规则20' AS 规则描述 UNION ALL SELECT'A_J_0002_03' AS 规则编号,'规则21' AS 规则描述 UNION ALL SELECT'A_J_0002_04' AS 规则编号,'规则22' AS 规则描述 UNION ALL SELECT'A_J_0002_05' AS 规则编号,'规则23' AS 规则描述 UNION ALL SELECT'A_J_0002_06' AS 规则编号,'规则24' AS 规则描述 UNION ALL SELECT'A_J_0002_07' AS 规则编号,'规则25' AS 规则描述 UNION ALL SELECT'A_J_0003_01' AS 规则编号,'规则26' AS 规则描述 UNION ALL SELECT'A_J_0003_02' AS 规则编号,'规则27' AS 规则描述 UNION ALL SELECT'A_J_0003_05' AS 规则编号,'规则28' AS 规则描述 ) t1LEFT JOIN RAMS_TRIAL_CHECKLIST t2 ON t2.RULE_CODE like concat('%',t1.规则编号,'%')LEFT JOIN RAMS_TRIAL_CHECKLIST_EXT t3 ON t2.CHECKLIST_ID = t3.CHECKLIST_ID WHEREDATE( t2.UPDATE_TIME ) = CURDATE( ) - INTERVAL 1 DAY GROUP BY t1.规则编号,t1.规则描述;
二、查询结果