题解 | #返回订单数量总和不小于100的所有订单的订单号#
返回订单数量总和不小于100的所有订单的订单号
https://www.nowcoder.com/practice/ff77e82b59544a15987324e19488aafd
SELECT order_num FROM ( SELECT order_num, SUM(quantity) FROM OrderItems GROUP BY order_num HAVING SUM(quantity) >= 100 ) a ORDER BY order_num
题解:
1.任务:查询订单号
2.限制:订单数量总和不低于100
3.排序
思路:
1.先写查询语句,查询订单号
2.要计算每个订单号的订单数量之和,使用sum函数和group by语句,
3.排序order by