select 
t2.goods_id, 
t1.name,
t1.weight,
sum(t2.count)
from goods t1
join trans t2 on t1.id = t2.goods_id
group by t2.goods_id,t1.name,t1.weight
having t1.weight >= 20 and t1.weight < 50
order by t2.goods_id;