select a.product_line,b.region,b.channel_name, sum(c.sale_amount) as total_sale_amount, count(*) as total_sale_quantity from oppo_products a join sales_data c using(product_id) join sales_channels b using(channel_id) group by a.product_line,b.region,b.channel_name,b.channel_id order by a.product_line,b.channel_id
注意:group by 后面一定要加channel_id分组,若channel_name一样,但channel_id不同,就不会被划分到一组计算。