select 
t1.id 
,t1.name 
,t1.weight
,sum(t2.count) total 
from goods t1
join trans t2
on t1.id = t2.goods_id
where t1.weight < 50
group by 1,2,3
having sum(t2.count) > 20
order by 1