我正在尝试使用类似case的语句为一列创建多个4行值:
Case when time_zero = '00' then 'zero' case when time_zero ='01' then 'zeroOne' case when Day_of_Year ='Today' then '2day' when Day_of_Year ='yesterday' then 'yesterday end end as Ouput_column
这是针对oracle 11g
Case when time_zero = '00' then 'zero' case when time_zero ='01' then 'zeroOne' case when Day_of_Year ='Today' then '2day' when Day_of_Year ='yesterday' then 'yesterday end end as Output_column
预期结果Output_column
zeroOne
2day
zero
yesterday
答案 0 :(得分:0)
这将创建新列:
select *,
case
when time_zero = '00' then 'zero'
when time_zero ='01' then 'zeroOne'
when Day_of_Year ='Today' then '2day'
when Day_of_Year ='yesterday' then 'yesterday'
end as Output_column
from tablename
该列的值首先取决于列time_zero
的值,其次取决于列Day_of_Year
的值。
如果没有任何条件适用,则为null
。