Hive中的rollup

1.rollup有什么用?

  可以实现从右到左递减多级的统计,显示统计某一层次结构的聚合。

2.举个例子

select device_id,os_id,app_id,client_v,channel,count(user_id) 
from test_1 
group by device_id,os_id,app_id,client_v,channel with rollup;

等价于

select device_id,os_id,app_id,client_v,channel,count(user_id) 
from test_1 
group by device_id,os_id,app_id,client_v,channel 
grouping sets ((device_id,os_id,app_id,client_v,channel),(device_id,os_id,app_id,client_v),(device_id,os_id,app_id),(device_id,os_id),(device_id),());

 

posted @ 2020-12-08 19:39  山中何事  阅读(1753)  评论(0)    收藏  举报