需要找出某个时间段内卖出商品数量大于5的次数,请问使用SUM和COUNT吗?应该怎么用?
建議提供一些不敏感的資料,讓其他人可以根據 “實際例子” 提供建議。
select 商品,count(1) as 次数 from 表名 where 时间段 group by 商品 having count(1)>5
select 商品,count(1) from 表 where 时间 between 开始时间 and 结束时间 group by 商品 having sum(商品数量)>5