有人可以帮助转换下面Oracle
中的Hive
查询吗?
select *
from tbl_my_details a
where decode(a.my_code,'ALL','99','01','01','02','02','03','03','04','04','06','06',
'Other') = a.my_content
答案 0 :(得分:1)
您可以按以下方式使用case..when
结构:
select *
from tbl_my_details a
where (
case
when a.my_code = 'ALL' then '99'
when a.my_code in ('01','02','03','04','06') then a.my_code
else 'Other'
end
) = a.my_content;
答案 1 :(得分:1)
在两个数据库中,最好使用简单的布尔逻辑:
select *
from tbl_my_details a
where (a.my_code in ('01', '02', '03', '04', '06') and a.my_content = a.my_code) or
(a.my_code = 'ALL' and a.my_content = '99') or
(a.my_code not in ('01', '02', '03', '04', '06', 'ALL') and a.my_content = 'Other')