题解 | #计算总和#

计算总和

https://www.nowcoder.com/practice/d8a624021183454586da94d280cc8046

select
    order_num,
    sum(item_price * quantity) total_price
from
    OrderItems
group by
    order_num
   having  total_price >= 1000
order by
    order_num asc
  1. where后面不能直接加聚合函数(分组函数),我们也可以这样记忆:where后面只能跟表中存在的字段。
  2. having 不能单独使用,必须跟 group by 联合使用。
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务