有没有人知道为什么这段代码不起作用?
create table2 as
select
*,
1 as count,
case
when a=1 then
case
when tx="A_L" then "L"
when tx="B_A" then "A"
when tx="C_E" then "E"
when tx in ("E_V","D_M","H_O","I_D") then "Other"
when tx="F_S" then "S"
when tx="G_L" then "L"
end
when b=1 then
case
when tx="A_L" then "L"
when tx="B_A" then "A"
when tx="C_E" then "E"
end
else
case
when tx="A_L" then "L"
when tx="B_A" then "A"
when tx="C_E" then "E"
when tx in ("D_M","E_V","F_S","H_O","I_D") then "Other"
when tx="G_L" then "L"
end
end as tx1
from table1
或者有更简单的方法吗?我在proc sql语句中编写它并将其推送到Hadoop(因此它需要与HiveQL兼容)。
答案 0 :(得分:5)
使用AND或OR子句将嵌套的Case语句组合成一个case语句。这样可以。
答案 1 :(得分:0)
而不是测试,这个更具可读性。
concat