题解 | 每个商品的销售总额
select t1.name as product_name ,sum(t2.quantity) as total_sales ,row_number() over(partition by t1.category order by category asc,sum(t2.quantity) desc) as category_rank from products as t1 inner join orders as t2 on t1.product_id = t2.product_id group by t1.name,t1.category;
name与类别都需要分组!