Prova detta:
Select code, sum(qtd)
from (
select code, qtd from sales
union all
select code, qtd from items
) as innerTable
group by code
Observera att det måste vara UNION ALL och inte UNION om du vill behålla alla rader – UNION tar bort dubbletter och kan ge fel summa.