我在检查以下条件时的case语句中出现语法错误:
((RAP10B.CLMSRC = '2', RAP01.EFFDT - 3 years <= RAP10.LOSSDT < RAP01.EFFDT)
OR
(RAP10B.CLMSRC <> '2', RAP01.EFFDT - 3 years <= RAP10.LOSSDT < RAP01.EFFDT - 60 days)
下面是我正在使用的代码。
CASE
WHEN RAP10B.CLMSRC = '2'
THEN rap10.lossdt_t BETWEEN Add_months(rap01.teffdt_t, - 36) AND rap01.teffdt_t
WHEN RAP10B.CLMSRC <> '2'
THEN rap10.lossdt_t BETWEEN Add_months(rap01.teffdt_t, - 36) AND (rap01.teffdt_t - 60)
END
错误消息是“ ORA-00905:缺少关键字”。但是我找不到丢失的东西。
答案 0 :(得分:1)
通常最好在AND
子句中使用OR
/ WHERE
构造而不是case
表达式:
WHERE (RAP10B.CLMSRC = '2'
AND rap10.lossdt_t BETWEEN Add_months(rap01.teffdt_t, - 36) AND rap01.teffdt_t)
OR (RAP10B.CLMSRC <> '2'
AND rap10.lossdt_t BETWEEN Add_months(rap01.teffdt_t, - 36) AND (rap01.teffdt_t - 60))
答案 1 :(得分:0)
您是否正在寻找类似的东西?
CASE
WHEN RAP10B.CLMSRC = '2'
AND rap10.lossdt_t BETWEEN Add_months(rap01.teffdt_t, - 36)
AND rap01.teffdt_t THEN <your_column>
WHEN RAP10B.CLMSRC <> '2'
AND rap10.lossdt_t BETWEEN Add_months(rap01.teffdt_t, - 36)
AND (rap01.teffdt_t - 60) THEN <your_column>
END
答案 2 :(得分:0)
尝试以下-
CASE
WHEN RAP10B.CLMSRC = '2'
and rap10.lossdt_t BETWEEN Add_months(rap01.teffdt_t, - 36) AND rap01.teffdt_t then yourval
WHEN RAP10B.CLMSRC <> '2'
and rap10.lossdt_t BETWEEN Add_months(rap01.teffdt_t, - 36) AND (rap01.teffdt_t - 60) yourval1
END