题解 | #返回每个顾客不同订单的总金额#
返回每个顾客不同订单的总金额
https://www.nowcoder.com/practice/ce313253a81c4947b20e801cd4da7894
select o.cust_id, ( select sum(q.item_price*q.quantity) from OrderItems q where q.order_num = o.order_num ) total_order from Orders o order by total_order desc #主查询中的total_order列将子查询的结果显示为主查询的一部分。故结果集中的每一行都有相应的cust_id和计算出的total_order。