The code below works fine.
(SELECT (CASE
WHEN (PA.ACTOR_KIND = 5) THEN
(SELECT POP.KDS_TEKLIF_TUT_TL)
ELSE 0 END) AS Expr1) AS YKF_CUSTOMER_LIMIT
However,when I add another "when" condition it gives error.
(SELECT (CASE
WHEN (PA.ACTOR_KIND = 5) THEN
(SELECT POP.KDS_TEKLIF_TUT_TL)
WHEN (PA.ACTOR_KIND = 10) THEN
(SELECT POP.KDS_ALICI_LIM_TL)
ELSE 0 END) AS Expr1) AS YKF_CUSTOMER_LIMIT
It seems all logical to me but not for sql
**Edit It was caused by typo error,there is nothing wrong with those statements.
答案 0 :(得分:2)
I don't know if this will fix your problem, but you don't need SELECT
for the WHEN
clauses:
SELECT (CASE WHEN PA.ACTOR_KIND = 5
THEN POP.KDS_TEKLIF_TUT_TL
WHEN PA.ACTOR_KIND = 10
THEN POP.KDS_ALICI_LIM_TL
ELSE 0
END) AS YKF_CUSTOMER_LIMIT
You don't need to give the expression a name in the subquery as well as in the outer query. One name is enough. (Although that doesn't cause your error.)