select a.id1,b.snum2-a.snum1
from (select exdeGoodsID as id1,sum(exdeQuantity)as snum1 from ExdertDetail group by exdeGoodsID) as a
full JOIN (select imdeGoodsId as id2,sum(imdeQuantity) as snum2 from importDetail group by imdeGoodsID) as b on a.id1=b.id2