我有什么
customer_id
1
2
2
1
3
我想要的是(对于所有客户ID&1,我希望将其标记为有效,其余客户ID在新列中无效" warining_customer_id"
customer_id warining_customer_id
1 Valid
2 Invalid
2 Invalid
1 Valid
3 Invalid
答案 0 :(得分:1)
这是一个例子
SELECT customer.customer_id AS customer_id,
CASE WHEN customer.customer_id = 1 THEN 'Valid' ELSE 'Invalid' END
AS warning_customer_id
FROM (SELECT 1 AS customer_id FROM DUAL
UNION ALL
SELECT 2 AS customer_id FROM DUAL) customer