Código SQL:
Ver originalSELECT t1.codigo,t1.resultado-t2.resultado AS total FROM(
SELECT codigo,ROUND(SUM(importe),2) AS 'resultado' FROM tabla1 GROUP BY codigo
) AS t1 LEFT JOIN
(SELECT codigo,ROUND(SUM(importe),2) AS 'resultado' FROM tabla2 GROUP BY codigo) AS t2 ON t1.codigo=t2.codigo