题解 | #返回订单数量总和不小于100的所有订单的订单号#
返回订单数量总和不小于100的所有订单的订单号
http://www.nowcoder.com/practice/ff77e82b59544a15987324e19488aafd
SELECT
order_num
FROM
OrderItems
where
quantity >= 100
GROUP BY
order_num
ORDER BY
order_num
;
分析
关键词:having
用法:
where---过滤过滤指定的行 having--过滤分组,与group by连用 代码
select
order_num
from
OrderItems
group by
order_num
having
sum(quantity)>=100
order by
order_num
;