有人可以协助我将这个SQL
查询转换为hive
以获得相同的输出吗?
下面是查询
select count(email),
case substring_index(email,"@",-1)
when 'gmail.com' then 'GMAIL'
when 'googlemail.com' then 'GMAIL'
when 'yahoo.com' then 'YAHOO'
when 'ymail.com' then 'YAHOO'
else 'OTHER'
END as DOMAIN
from DATA1 group by 2;
答案 0 :(得分:0)
select count(email),
case split(email,'@')[1]
when 'gmail.com' then 'GMAIL'
when 'googlemail.com' then 'GMAIL'
when 'yahoo.com' then 'YAHOO'
when 'ymail.com' then 'YAHOO'
else 'OTHER'
end as DOMAIN
from DATA1
group by
case substring_index(email,"@",-1)
when 'gmail.com' then 'GMAIL'
when 'googlemail.com' then 'GMAIL'
when 'yahoo.com' then 'YAHOO'
when 'ymail.com' then 'YAHOO'
else 'OTHER'
end;
如果您希望group by 2
工作,请阅读group by position syntax并相应地应用于您的配置单元版本。