Hive Join - 基于多个条件
Posted
技术标签:
【中文标题】Hive Join - 基于多个条件【英文标题】:Hive Join - based on multiple conditions 【发布时间】:2017-08-19 09:14:14 【问题描述】:在我的一张表中,其中包含日期和事件列。
select * from event
它返回,
date event
2016-03-20 Launch
2016-03-20 delete
2016-03-20 Launch
2016-03-20 launch
2016-03-19 delete
2016-03-19 stop
我希望结果使用按日期分组
date | count(Luanch) | count(delete) | count(stop)
【问题讨论】:
【参考方案1】:select date
,count(case when event = 'Launch' then 1 end) as count_Launch
,count(case when event = 'delete' then 1 end) as count_delete
,count(case when event = 'stop' then 1 end) as count_stop
from event
group by date
;
date | count_Launch | count_delete | count_stop
------------+--------------+--------------+-------------
2016-03-19 | 0 | 1 | 1
2016-03-20 | 2 | 1 | 0
【讨论】:
它抛出,这种类型的查询不支持,还有其他解决方案吗? ,count(case event when 'launch' then 1 end ) as Launch,这在雅典娜有效 这没有任何意义。您无法使用"
限定列名?
嘟嘟,我是新手,不知道为什么它在雅典娜不起作用,让我看看为什么。以上是关于Hive Join - 基于多个条件的主要内容,如果未能解决你的问题,请参考以下文章