题解 | #返回顾客名称和相关订单号以及每个订单的总价#

返回顾客名称和相关订单号以及每个订单的总价

https://www.nowcoder.com/practice/4dda66e385c443d8a11570a70807d250

select c.cust_name,f.order_num,f.OrderTotal
from Customers c,
(select o.cust_id,o.order_num,sum(oi.quantity*oi.item_price) OrderTotal
from Customers c,Orders o,OrderItems oi
where c.cust_id=o.cust_id and o.order_num=oi.order_num
group by o.cust_id,o.order_num) f
where c.cust_id=f.cust_id
order by c.cust_name,f.order_num;

#sql#
全部评论

相关推荐

投递字节跳动等公司10个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务