题解 | #返回顾客名称和相关订单号以及每个订单的总价#
返回顾客名称和相关订单号以及每个订单的总价
https://www.nowcoder.com/practice/4dda66e385c443d8a11570a70807d250
先联结Customers、Orders这两个表,再联结OrderItems表;
select cust_name,
order_num ,
round((select sum(quantity *item_price )
from OrderItems
where OrderItems.order_num =Orders.order_num),3) OrderTotal
from Customers ,Orders
where Customers.cust_id = Orders.cust_id
order by cust_name,order_num;