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

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

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;
全部评论

相关推荐

04-08 23:37
已编辑
东华大学 结构工程师
点赞 评论 收藏
分享
zaakfung:26届不应该春招吗 为啥还实习
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务