這個Oracle查詢有什麼問題。我正在嘗試嵌套的表達式,但無法找到查詢失敗的原因。嵌套的case表達式在sql查詢中給出錯誤
SELECT USER_ID,
ADVISER_FORENAME,
ADVISER_SURNAME,
AGENT_CODE,
'[email protected]' AS EMAIL_ADDRESS,
SUBMISSION_DATE,
STATUS_CHANGED_DATE,
CASE
WHEN (
CASE
WHEN TO_CHAR(TRUNC(status_changed_date), 'DY') IN ('fri','sat','sun')
THEN ((TRUNC(STATUS_CHANGED_DATE) - (TRUNC(SUBMISSION_DATE)))>4)
ELSE ((TRUNC(STATUS_CHANGED_DATE) - (TRUNC(SUBMISSION_DATE)))>6)
END)
THEN 'B'
ELSE 'A'
END AS CATEGORY_CODE,
PLAN_REF,
PRODUCT_CODE,
CASE
WHEN ((TRUNC(STATUS_CHANGED_DATE) - TRUNC(SUBMISSION_DATE))>4)
THEN 'IPP'
ELSE 'ICP'
END AS TOUCHPOINT_NAME
FROM PIPELINE_PLAN
WHERE STATUS =26
AND PRODUCT_TYPE =1
AND (TRUNC(STATUS_CHANGED_DATE) - TRUNC(SUBMISSION_DATE))<=4;
當我嘗試運行,它提供了以下錯誤:
ORA-00907:缺少右括號 00907. 00000 - 「缺少右括號」 *原因:
*動作: 的錯誤線:53列:84
我檢查了缺少的括號,但沒有發現。
請幫忙。