题解 | #返回订单数量总和不小于100的所有订单的订单号#
返回订单数量总和不小于100的所有订单的订单号
http://www.nowcoder.com/practice/ff77e82b59544a15987324e19488aafd
- select order_num
- from OrderItems
- group by order_num
- having sum(quantity) >= 100
- order by order_num asc
需要对订单号进行分组,WHERE 关键字无法与聚合函数一起使用,所以用having,升序为asc