一.分组聚合:
1.分组
示例:
统计order_items表中销售量排名前十的商品
hive> select order_item_product_id,sum(order_item_quantity) as total
> from order_items
> group by order_item_product_id
> order by total desc limit 10;
2.基础聚合
示例:
统计每个商品大类下的商品分类
hive> select category_department_id,count(category_name),collect_set(category_name)
> from categories group by category_department_id;
3.高级聚合
(1)GROUPING SETS
(2)GUBE与ROLLUP