# 以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