Data Analysis
hive sql - 다양한 group by - grouping sets , with cube
keepgroovin'
2022. 5. 1. 21:25
select A,B,C, count(distinct cust_id)
from dataset
group by A,B,C
1. grouping sets
select A,B,C, grouping__id, count(distinct cust_id)
from dataset
group by A,B,C
grouping sets ((),(A),(B),(C),(A,C),(B,C),(A,B,C))
2. cube
select A,B,C, grouping__id, count(distinct cust_id)
from dataset
group by A,B,C
with cube
3. roll up
select A,B,C, grouping__id, count(distinct cust_id)
from dataset
group by A,B,C
with rollup