题解 | 返回每个顾客不同订单的总金额
select cust_id, sum(total_ordered) total_ordered from ( select cust_id, item_price * quantity total_ordered from OrderItems ori join Orders ord on ori.order_num = ord.order_num ) a group by cust_id order by total_ordered desc
select cust_id, sum(total_ordered) total_ordered from ( select cust_id, item_price * quantity total_ordered from OrderItems ori join Orders ord on ori.order_num = ord.order_num ) a group by cust_id order by total_ordered desc
相关推荐