select a.id,a.name,a.weight,sum(b.count) as total from goods a join trans b on a.id=b.goods_id where weight < 50 group by b.goods_id having total >20 order by a.id;
select a.id,a.name,a.weight,sum(b.count) as total from goods a join trans b on a.id=b.goods_id where weight < 50 group by b.goods_id having total >20 order by a.id;