hiveQL if语句在一行重新组合

Ger*_*Gum 3 hive hiveql

查询:

select IF(type='view', count(*), 0), IF(type='click', count(*), 0)
from ad_events
where year=2013 and month=01 and day=18 and (hour=01 or hour=02)
group by type
Run Code Online (Sandbox Code Playgroud)

结果:

      _c0       _c1
0      0         0
1      0         0
2      0       1368
3      0         0
4      0         0
5      0         0
6      0         0
7      0         0
8   277917       0
9      0         0
Run Code Online (Sandbox Code Playgroud)

反正有没有像这样的结果?:

      _c0       _c1
0    277917     1368
Run Code Online (Sandbox Code Playgroud)

Ger*_*Gum 5

好吧,我刚刚在嵌套查询中做到了:

select SUM(c), SUM(v)
from (
select tracking_id, IF(type='view', count(*), 0) AS v, IF(type='click', count(*), 0) AS c
from ad_events
where year=2013 and month=01 and day=18
group by tracking_id, type
) t2
Run Code Online (Sandbox Code Playgroud)