The problem is that you're joining 2 rows against 2 rows and getting 4 rows as a result, then aggregating the 4 rows...
(Each row in Entrada matches with BOTH rows in Saida.)
Entrada: Saida:
n_serie, qtd n_serie, qtd a - b
'1234' , 50 '1234' , 2 48
'1234' , 50 '1234' , 49 1
'1234' , 2 '1234' , 2 0
'1234' , 2 '1234' , 49 -47
-----
2
-----
What you need to do is aggregate each table first, then join them together.
(
SELECT n_serie, SUM(qtd) AS qtd
FROM Entrada
GROUP BY n_serie
)
AS entrada
LEFT JOIN
(
SELECT n_serie, SUM(qtd) AS qtd
FROM Saida
GROUP BY n_serie
)
AS Saida
ON Saida.n_serie = Entrada.n_serie
Which would give you...
Entrada: Saida:
n_serie, qtd n_serie, qtd a - b
'1234' , 52 '1234' , 51 1