SELECT t1.org_id AS sonOrgId, t1.orgName AS sonOrgName, t1.id AS routeBasesectionId, t1.`name` AS routeBasesectionName, t1.nature, zw.billCode AS diseaseTypeSn, COUNT( t3.id ) AS num, ( CASE WHEN sum( CASE WHEN zw.`status` = '2' THEN zw.workNum END ) IS NOT NULL THEN sum( CASE WHEN zw.`status` = '2' THEN zw.workNum END ) WHEN sum( CASE WHEN zw.`status` = '1' THEN zw.workNum END ) IS NOT NULL THEN sum( CASE WHEN zw.`status` = '1' THEN zw.workNum END ) ELSE sum( CASE WHEN zw.`status` = '0' THEN zw.workNum END ) END ) AS totalAmount FROM mat_zx_section t3 JOIN base_bridge bb ON bb.id = t3.qshMainId LEFT JOIN mat_zx_workload zw ON zw.mainId = t3.id LEFT JOIN base_e_route_basesection t1 ON t3.baseRoute = t1.id LEFT JOIN main_construct t4 ON t3.constructId = t4.id -- 施工申请 LEFT JOIN main_construct_check t5 ON t5.id = t3.acceptanceId -- 施工申请验收 WHERE t5.process_status = '100' GROUP BY zw.billCode, t1.id, t1.nature, t1.org_id ORDER BY t1.org_id, t1.id, zw.billCode UNION ALL SELECT son_org_id AS sonOrgId, son_org_name AS sonOrgName, route_id AS routeBasesectionId, route_name AS routeBasesectionName, route_type AS nature, disease_type_sn AS diseaseTypeSn, num AS num, total_amount AS totalAmount FROM base_history_repair_statistics;这条sql语句执行失败
时间: 2024-03-24 20:42:03 浏览: 162
cheakmin.github.io
这个 SQL 语句可能会因为分号(;)导致执行失败。请尝试将分号(;)删除,然后再次执行该 SQL 语句。如下所示:
```
SELECT t1.org_id AS sonOrgId, t1.orgName AS sonOrgName, t1.id AS routeBasesectionId, t1.`name` AS routeBasesectionName, t1.nature, zw.billCode AS diseaseTypeSn, COUNT( t3.id ) AS num, ( CASE WHEN sum( CASE WHEN zw.`status` = '2' THEN zw.workNum END ) IS NOT NULL THEN sum( CASE WHEN zw.`status` = '2' THEN zw.workNum END ) WHEN sum( CASE WHEN zw.`status` = '1' THEN zw.workNum END ) IS NOT NULL THEN sum( CASE WHEN zw.`status` = '1' THEN zw.workNum END ) ELSE sum( CASE WHEN zw.`status` = '0' THEN zw.workNum END ) END ) AS totalAmount FROM mat_zx_section t3 JOIN base_bridge bb ON bb.id = t3.qshMainId LEFT JOIN mat_zx_workload zw ON zw.mainId = t3.id LEFT JOIN base_e_route_basesection t1 ON t3.baseRoute = t1.id LEFT JOIN main_construct t4 ON t3.constructId = t4.id -- 施工申请 LEFT JOIN main_construct_check t5 ON t5.id = t3.acceptanceId -- 施工申请验收 WHERE t5.process_status = '100' GROUP BY zw.billCode, t1.id, t1.nature, t1.org_id ORDER BY t1.org_id, t1.id, zw.billCode UNION ALL SELECT son_org_id AS sonOrgId, son_org_name AS sonOrgName, route_id AS routeBasesectionId, route_name AS routeBasesectionName, route_type AS nature, disease_type_sn AS diseaseTypeSn, num AS num, total_amount AS totalAmount FROM base_history_repair_statistics
```
阅读全文