我在查询中使用“CASE WHEN”来获取此条件或该条件的值。我得到“Missing Right Paraethesis”错误。请告诉我要调整查询的位置。
SELECT * FROM MNDTRY_NODE_COND
WHERE (MNDTRY_NODE_COND.OPTN_CD IN
CASE WHEN EXISTS
(SELECT * FROM MNDTRY_NODE_COND
WHERE MNDTRY_NODE_COND.OPTN_CD IN ('GAN','4BB','RFF','U32','VVT','OAP'))
THEN ('GAN','4BB','RFF','U32','VVT','OAP')
ELSE ('*') END);
答案 0 :(得分:2)
SELECT *
FROM MNDTRY_NODE_COND
WHERE OPTN_CD IN ('GAN','4BB','RFF','U32','VVT','OAP')
union all
SELECT *
FROM MNDTRY_NODE_COND
WHERE OPTN_CD = '*'
and not exists (SELECT * FROM MNDTRY_NODE_COND WHERE OPTN_CD IN ('GAN','4BB','RFF','U32','VVT','OAP'))