好吧,我觉得我错过了一些基本的东西。t、 t型
SELECT
CATEGORY,
PRODUCT,
(CASE
WHEN PRODUCT_DETAIL = 'STRAWBERRY' AND some_condition = x THEN 'REQUIRE REVIEW'
WHEN PRODUCT_DETAIL = 'COD' AND some_condition = x THEN 'REQUIRE REVIEW'
WHEN PRODUCT_DETAIL = 'MILK' AND some_condition = x THEN 'REQUIRE REVIEW'
WHEN PRODUCT_DETAIL = 'BREAD' AND some_condition = x THEN 'REQUIRE REVIEW'
...
WHEN PRODUCT_DETAIL = 'ICE CREAM' AND some_condition = x THEN 'REQUIRE REVIEW'
ELSE 'GOOD'
END) AS PRODUCT_CONDITION
FROM
MAIN_DATABASE
我想我的问题是,既然{and some\u condition=x then'require review}都是一样的,有没有办法把代码缩短成某种形式的
WHEN PRODUCT_DETAIL = ('STRAWBERRY', 'COD', 'MILK', ... , 'ICE CREAM') AND some_condition = x
THEN 'REQUIRE REVIEW'
ELSE 'GOOD'
或者它的一些变体?
谢谢,cn
1条答案
按热度按时间5gfr0r5j1#
你可以用
IN
: