题解 | #获得积分最多的人(一)#
商品交易(网易校招笔试真题)
http://www.nowcoder.com/practice/f257dfc1b55e42e19eec004aa3cb4174
碰到这种题,就想到子查询。害。。。。。。
select g.id, g.name, g.weight, temp.total from
goods g join
(select goods_id, sum(t.count) as total FROM trans t
GROUP BY goods_id HAVING total > 20) temp
ON g.id = temp.goods_id where g.weight < 50 ORDER BY g.id;