SELECT table2.*,
(SELECT Sum(qtde)
FROM table1
WHERE table1.cnes = table2.cnes
AND table1.procedimento = table2.procedimento
AND table1.mes = table2.mes
AND table1.ano = table2.ano
GROUP BY cnes,
procedimento,
ano,
mes) AS soma
FROM table2
SELECT table2.*,
(SELECT Sum(qtde)