select A.字段1,(sum(A.字段2)-(select sum(B.字段2)
      from B
      where B.字段1 =A.字段1))as 数量
into #a 
from A
group by A.字段1
select * from #a where 数量<>0