Ver originalPrueba esto:SELECT SUM(tr.resta) suma from (SELECT (TABLA1.importe - TABLA2.importe) restaFROM TABLA1 t1INNER JOIN TABLA2 t2ON t1.usr = t2.usrAND MONTH(t1.fecha) = 'x')tr;