题解 | #商品交易(网易校招笔试真题)#
商品交易(网易校招笔试真题)
https://www.nowcoder.com/practice/f257dfc1b55e42e19eec004aa3cb4174
select g.id id, g.name name , g.weight weight, sum(t.count) total from goods g inner join trans t on g.id=t.goods_id group by t.goods_id having total>20 and g.weight<50 order by g.id;
题目要求查找购买个数超过20,质量小于50的商品,按照商品id升序排序,我一开始只是将购买个数以为是coun那一列仔细一看原来交易表相同的商品有多个需要进行分组聚合,聚合后对于购买个数和质量进行过滤,记得要排序!!