SELECT TXCM_CATEGORY_ID,
TXCM_CATEGORY_NAME,
TXCM_MAIN_CATEGORY_ID,
TXCM_PRT_CATEGORY_ID,
CASE
WHEN TXCM_PRT_CATEGORY_ID = 3097 THEN TXCM_PRT_CATEGORY_ID = 0
ELSE TXCM_PRT_CATEGORY_ID = 6
END
FROM TXODOC_CATEGORY_MASTER;
请帮帮我......谢谢
答案 0 :(得分:0)
尝试这样的事情:
SELECT TXCM_CATEGORY_ID,
TXCM_CATEGORY_NAME,
TXCM_MAIN_CATEGORY_ID,
TXCM_PRT_CATEGORY_ID,
CASE
WHEN TXCM_PRT_CATEGORY_ID = 3097 THEN 0
ELSE 6
END AS TXCM_PRT_CATEGORY_ID
FROM TXODOC_CATEGORY_MASTER;
答案 1 :(得分:0)
我担心你的CASE陈述有点搞砸了。
correct syntax就是这样。
简单CASE表达式:
CASE input_expression
WHEN when_expression THEN result_expression [ ...n ]
[ ELSE else_result_expression ]
END
搜索CASE表达式:
CASE
WHEN Boolean_expression THEN result_expression [ ...n ]
[ ELSE else_result_expression ]
END
如果我没有弄错你的话,你可以使用搜索过的CASE表达式,就像这样。
SELECT
TXCM_CATEGORY_ID,
TXCM_CATEGORY_NAME,
TXCM_MAIN_CATEGORY_ID,
TXCM_PRT_CATEGORY_ID,
CASE TXCM_PRT_CATEGORY_ID
WHEN 3097 THEN 0
ELSE 6
END
FROM TXODOC_CATEGORY_MASTER