子查询聚合函数与外联结的结合使用

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