力扣1069(MySQL)-产品分析Ⅱ(简单)

题目:

编写一个 SQL 查询,按产品 id product_id 来统计每个产品的销售总量。

查询结果格式如下面例子所示:

 解题思路:

没有用到product表,直接在sales表中使用聚合函数:

1 select product_id,sum(quantity) as total_quantity
2 from sales
3 group by product_id;

posted on 2023-04-08 09:29  我不想一直当菜鸟  阅读(24)  评论(0编辑  收藏  举报