create table #
(AreaCD int ,DeptCD int , ExpTypeCD int , BudgetMny numeric(10,2) )create table #1
(AreaCD int ,DeptCD int , ExpTypeCD int , BudgetMny numeric(10,2) )insert into #
select 1,  2,  3,  20.00 union
select 2,  5,  5,  30.00
insert into #1
select 1,  2,  3,  50.00 union
select 2,  4,  6,  30.00select A.AreaCD , A.DeptCD , A.BudgetMny - isnull(b.BudgetMny,0) from # a
 left join #1 b
on   a.AreaCD = b.AreaCD
and  a.DeptCD = b.DeptCD