连接goods和trans两表并限制weight小于50。根据商品id分组汇总并求出每组销售数量合sum(t.count),然后限制sum(t.count)>20。最后按照商品id排序
select g.id, g.name, g.weight, sum(t.count) as total from
goods as g, trans as t
where g.weight < 50 and g.id = t.goods_id
group by g.id
having sum(t.count) > 20
order by g.id