Hive OLAP多维聚合函数(2)

结果
departmentid    classid summath uv
NULL            NULL    1654    20
department1    NULL    718    9
department1    class1  410    5
department1    class2  308    4
department2    NULL    936    11
department2    class1  520    6
department2    class2  416    5

等价于union all:
-- 下钻
select departmentid,classid,sum(math) as sumMath,count(distinct studentid) as uv from student_scores
group by departmentid,classid
union all
select departmentid,null as classid,sum(math) as sumMath,count(distinct studentid) as uv from student_scores
group by departmentid,null
-- 上卷
union all
select null as departmentid,null as classid,sum(math) as sumMath,count(distinct studentid) as uv from student_scores
group by null,null;

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/2984d3a2ed82696f15f5edebf7ae8226.html