select Name,Sum(Num1) Num1,Sum(Num2) Num2 From
(
select Name,Num1,0 as Num2
from A
Union All
select Name,0 as Num1,Num2
from B
) C
group by C.Name
select Name,Sum(Num1) Num1,Sum(Num2) Num2 From
(
select Name,Num1,0 as Num2
from A
Union All
select Name,0 as Num1,Num2
from B
) C
group by C.Name