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

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

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

  1. 子查询的方法
  • group by 在where之后,order by之前
  • 子查询只能查一列
  • 必须在子查询内使用where联结
select cust_name,o.order_num,(
    select sum(quantity*item_price) 
    from OrderItems oi
    where oi.order_num=o.order_num
    group by order_num
) as OrderTotal
from Customers c, Orders o
where c.cust_id=o.cust_id
order by cust_name,order_num

全部评论

相关推荐

钱嘛数字而已:辅导员肯定不能同意,不然你出事了,他要承担责任。但是,脚和脑子都长在你自己身上,使用它还需要向辅导员报告么? 辅导员必须按流程拒绝你,然后你拿出成年人的态度,做自己的选择。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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