题解 | #子查询,cust_id分组#
返回每个顾客不同订单的总金额
https://www.nowcoder.com/practice/ce313253a81c4947b20e801cd4da7894
在子查询结束之后,再对cust_id进行分组计算
select o.cust_id, sum(( select sum(oi.item_price * oi.quantity) from OrderItems as oi where oi.order_num = o.order_num ))as total_ordered from Orders as o group by o.cust_id order by total_ordered DESC