以下是简化后的SQL语句:
SELECT *
FROM (
SELECT temp.SUBWORKORDERNO AS flowid, temp.WORKLOAD
FROM UIRMS.TEMP_LINE_EXCEL_WORK temp
LEFT JOIN (
SELECT subWorkOrderNo, DECODE(SUBSTR(SUM(WORKLOAD), 1, 1), '.', '0'||SUM(WORKLOAD), SUM(WORKLOAD)) AS WORKLOAD
FROM (
SELECT subWorkOrderNo,
(CASE
WHEN subWorkState = 1 THEN 0
WHEN unit IN ('千米', '千米条') THEN ROUND(workLoad, 3)
WHEN unit = '米' THEN ROUND(workLoad, 0)
ELSE workLoad
END) AS workLoad
FROM (
SELECT LPCO.PROJECT_ID AS subWorkId,
LPCO.PROJECT_NAME AS subWorkName,
LPCO.PROJECT_CONTENT_ID AS subWorkContentId,
LPCO.PROJECT_CONTENT AS subWorkContent,
LPCO.IS_ZG AS subWorkType,
LPCO.FLOW_ID AS subWorkOrderNo,
LPCO.IS_ERROR AS subWorkState,
LOR.WORKLOAD AS workLoad,
LPC.UNIT AS unit
FROM LINE_PROJECT_CHILD_ORDER LPCO
INNER JOIN LINE_PROJECT_CODE LPC ON LPCO.PROJECT_CONTENT_ID = LPC.PROJECT_CONTENT_ID
LEFT JOIN LINE_OPERATE_RECORD LOR ON LPCO.FLOW_ID = LOR.CHILD_FLOW_ID AND LOR.stateflag = 0
)
) GROUP BY subWorkOrderNo
) db ON TO_CHAR(temp.SUBWORKORDERNO) = TO_CHAR(db.subWorkOrderNo)
WHERE TO_NUMBER(temp.WORKLOAD) != TO_NUMBER(db.WORKLOAD)
AND ROUND(temp.WORKLOAD, 3) != ROUND(db.WORKLOAD, 3)
AND temp.SUBWORKORDERNO IN (
SELECT SUBWORKORDERNO
FROM UIRMS.TEMP_LINE_EXCEL_WORK
WHERE TO_NUMBER(WORKLOAD) != (
SELECT DECODE(SUBSTR(SUM(WORKLOAD), 1, 1), '.', '0'||SUM(WORKLOAD), SUM(WORKLOAD)) AS WORKLOAD
FROM (
SELECT subWorkOrderNo,
(CASE
WHEN subWorkState = 1 THEN 0
WHEN