题解 | 分析各产品线在特定时间段内的销售情况
分析各产品线在特定时间段内的销售情况
https://www.nowcoder.com/practice/8a002dd7888b4247b6ac9228577bdbc3
# 以channel_name它进行排序的时候,它必须是select 后面出现过的数据
select product_line,region,channel_name,
sum(sale_amount) total_sale_amount,
count(product_id) total_sale_quantity
from (
select product_line,region,channel_name,sc.channel_id,sale_amount,sd.product_id
from sales_data sd join oppo_products o on sd.product_id = o.product_id
join sales_channels sc on sd.channel_id = sc.channel_id
) t1
group by product_line,region,channel_name
order by product_line
