题解 | #返回每个顾客不同订单的总金额#
返回每个顾客不同订单的总金额
https://www.nowcoder.com/practice/ce313253a81c4947b20e801cd4da7894
#子查询 select cust_id,total_order from Orders,(select order_num,sum(item_price*quantity) as total_order from OrderItems group by order_num)as tt where tt.order_num=Orders.order_num order by total_order desc #自然连接 select cust_id,total_order from Orders natural join (select order_num,sum(item_price*quantity) as total_order from OrderItems group by order_num)as tt where tt.order_num=Orders.order_num order by total_order desc #左连接 select cust_id,total_order from Orders left join (select order_num,sum(item_price*quantity) as total_order from OrderItems group by order_num)as tt on tt.order_num=Orders.order_num order by total_order desc #内连接 select cust_id,total_order from Orders inner join (select order_num,sum(item_price*quantity) as total_order from OrderItems group by order_num)as tt on tt.order_num=Orders.order_num order by total_order desc