题解 | #计算总和#
计算总和
https://www.nowcoder.com/practice/d8a624021183454586da94d280cc8046
SELECT order_num, SUM(item_price * quantity) total_price FROM OrderItems GROUP BY order_num HAVING total_price >= 1000 ORDER BY order_num
题解:
1.任务:计算每个订单的总订单金额,是单价*数量
2.限制:总金额不小于1000
3.排序
思路:
1.总金额,计算字段加聚合函数
2.每个订单,分组语句
3.不低于1000,having语句
4.排序order by