您的查询语句存在一处括号不匹配的错误。在子查询中,需要将日期参数用引号括起来。
以下是修改后的查询语句:
SELECT
t.FINAL_CHECK_LEVEL,
COUNT(*) AS level_count,
ROUND((COUNT(*) / total.total_count), 3) * 100 AS percentage,
CASE WHEN uu.original_order IS NOT NULL OR uu.original_order <> '' THEN uu.original_order ELSE u.work_order_name END AS workorder
FROM
UDT_FINAL_TEST_DATA t
LEFT JOIN TM_UNIT u ON u.name = t.unit_name
LEFT JOIN UDA_UNIT uu ON u.id = uu.id,
(
SELECT COUNT(*) AS total_count FROM UDT_FINAL_TEST_DATA
WHERE 1=1
AND FINAL_CHECK_LINE='M1U1'
AND create_time >= TO_DATE('2024-03-18 14:26', 'yyyy-mm-dd hh24:mi:ss')
AND create_time < TO_DATE('2024-03-19 20:26', 'yyyy-mm-dd hh24:mi:ss')
) total
WHERE 1=1
AND t.FINAL_CHECK_LINE='M1U1'
AND t.create_time >= TO_DATE('2024-03-18 14:26', 'yyyy-mm-dd hh24:mi:ss')
AND t.create_time < TO_DATE('2024-03-19 20:26', 'yyyy-mm-dd hh24:mi:ss')
GROUP BY
t.FINAL_CHECK_LEVEL, total.total_count;
请注意,您还需要根据实际情况修改其他部分的参数名称和筛选条件,并提供正确的时间范围。
内容由零声教学AI助手提供,问题来源于学员提问




