题解 | #返回顾客名称和相关订单号以及每个订单的总价#
返回顾客名称和相关订单号以及每个订单的总价
https://www.nowcoder.com/practice/4dda66e385c443d8a11570a70807d250
第一步:对OrderItems表进行分组求和,并得到一张新表n 第二步:对Customers、Orders、新表n三张表进行连接查询 第三步:排一下序 select c.cust_name,o.order_num,n.OrderTotal from Customers c,Orders o,(select order_num,sum(quantity*item_price) OrderTotal from OrderItems group by order_num) n where c.cust_id=o.cust_id and o.order_num=n.order_num order by cust_name,order_num;