题解 | #返回顾客名称和相关订单号以及每个订单的总价#
返回顾客名称和相关订单号以及每个订单的总价
https://www.nowcoder.com/practice/4dda66e385c443d8a11570a70807d250
不加DISTINCT就会输出很多重复的,求大神解答
select distinct
C.cust_name,
O.order_num,
O.OrderTotal
from
Customers
inner join (
select
Orders.order_num,cust_id,
quantity * item_price as OrderTotal
from
Orders
inner join OrderItems
where
Orders.order_num = OrderItems.order_num
) as O,Customers as C
where
C.cust_id = O.cust_id
order by
cust_name,
order_num
