题解 | 每个商品的销售总额
每个商品的销售总额
https://www.nowcoder.com/practice/6d796e885ee44a9cb599f47b16a02ea4
select t2.name AS product_name, sum(quantity) AS total_sales, row_number()over(partition by t2.category order by t2.category, sum(quantity) desc, t1.product_id) AS category_rank
from orders t1
inner join products t2
on t1.product_id = t2.product_id
group by t1.product_id, t2.name
查看10道真题和解析