题解 | #每个商品的销售总额#
每个商品的销售总额
http://www.nowcoder.com/questionTerminal/6d796e885ee44a9cb599f47b16a02ea4
SELECT product_id,
SUM(quantity) AS total_sales
FROM orders
GROUP BY product_id
)
SELECT name AS product_name,
total_sales,
RANK() OVER(PARTITION BY category ORDER BY total_sales DESC) AS category_rank
FROM tb1
JOIN products USING(product_id)
查看9道真题和解析