我有1列的表,并有以下数据
Status a1 i t a2 a3
Status| STATUSTEXT a1 | Active i | Inactive t | Terminated a2 | Active a3 | Active
SELECT status,CASE status WHEN 'a1' THEN 'Active' WHEN 'a2' THEN 'Active' WHEN 'a3' THEN 'Active' WHEN 'i' THEN 'Inactive' WHEN 't' THEN 'Terminated' END AS StatusText FROM stage.tst
有没有其他方法这样做,我不需要写当表达式3次活动状态和整个活动状态可以在一个单一的表达式检查?
您可以使用IN子句
原文链接:https://www.f2er.com/oracle/207470.html就像是
SELECT status,CASE WHEN STATUS IN('a1','a2','a3') THEN 'Active' WHEN STATUS = 'i' THEN 'Inactive' WHEN STATUS = 't' THEN 'Terminated' END AS STATUSTEXT FROM STATUS
看看这个演示