先帮你写语句:
if object_id('[tb1]') is not null drop table [tb1] 
 go 
create table [tb1]([mc] varchar(10),[sl] int)
insert [tb1] select 'A',100
union all select 'B',120
go
if object_id('[tb2]') is not null drop table [tb2] 
 go 
create table [tb2]([mc] varchar(10),[sl] int)
insert [tb2] select 'A',10
union all select 'A',20
union all select 'B',10
union all select 'B',20
union all select 'B',30
go
-->法一:
select *,结存=sl-isnull((select sum(sl) from tb2 where mc=tb1.mc),0) from tb1
/*
mc         sl          结存
---------- ----------- -----------
A          100         70
B          120         60(2 行受影响)
*/
-->法二:
select a.*,结存=a.sl-isnull(b.sl,0)
from tb1 a
  left join (select mc,sum(sl) sl from tb2 group by mc) b
    on a.mc=b.mc
/*
mc         sl          结存
---------- ----------- -----------
A          100         70
B          120         60(2 行受影响)
*/