题解 | #返回每个顾客不同订单的总金额#
返回每个顾客不同订单的总金额
https://www.nowcoder.com/practice/ce313253a81c4947b20e801cd4da7894
SELECT tb.cust_id, sum(tb.item_price * tb.quantity) as total_ordered FROM (SELECT item_price, quantity, cust_id from OrderItems as oi inner join Orders as o ON o.order_num = oi.order_num) as tb GROUP BY cust_id ORDER BY total_ordered DESC;