---------------
create table t1(f1 char(10),f2 int)
insert into t1
select 'A',6
union all
select 'B',7
union all
select 'A',10
create table t2 (f3 char(10),f1 char(10))
insert into t2
select 'X','A'
union all
select 'Y','B'
union all
select 'z','C'
------------
select sum(isnull(dbo.t1.f2 ,0)) as b,dbo.t2.f3
from dbo.t1 full outer join dbo.t2
on dbo.t1.f1 = dbo.t2.f1
group by dbo.t2.f3
------------
---------------
create table t1(f1 char(10),f2 int)
insert into t1
select 'A',6
union all
select 'B',7
union all
select 'A',10
create table t2 (f3 char(10),f1 char(10))
insert into t2
select 'X','A'
union all
select 'Y','B'
union all
select 'z','C'
------------
16 X
7 Y
0 z
---------------
create table t1(f1 char(10),f2 int)
insert into t1
select 'A',6
union all
select 'B',7
union all
select 'A',10
create table t2 (f3 char(10),f1 char(10))
insert into t2
select 'X','A'
union all
select 'Y','B'
union all
select 'z','C'
------------
select sum(isnull(dbo.t1.f2 ,0)) as b,dbo.t2.f3
from dbo.t1 full outer join dbo.t2
on dbo.t1.f1 = dbo.t2.f1
group by dbo.t2.f3