目录
1. 按年度列出每个商品销售总额
1.1 题目需求
从订单明细表(order_detail)中列出每个商品每个年度的购买总额。
Sku_id(商品id) | Year_date(年份) | Sku_sum(销售总额) |
---|---|---|
1 | 2021 | 102000.00 |
10 | 2021 | 29900.00 |
11 | 2021 | 16000.00 |
12 | 2021 | 413640.00 |
2 | 2021 | 60440.00 |
3 | 2021 | 180000.00 |
4 | 2021 | 318000.00 |
5 | 2021 | 121000.00 |
6 | 2021 | 64000.00 |
7 | 2021 | 25200.00 |
8 | 2021 | 151800.00 |
9 | 2021 | 194000.00 |
1.2 代码实现
hive>
select
sku_id,
year(create_date) year_date,
sum(price * sku_num) sku_sum
from
order_detail
group by
sku_id, year(create_date)
标签:sku,12,sum,year,Hive,2021,SQL,date,id
From: https://blog.csdn.net/qq_45115959/article/details/142314018