I have a table with the following structure:
codigo / signo /importe
With this select I get the following:
codigo / cargo / abono / saldo
But I want it to not show those that have zero balance (0), how do I filter that?
SELECT codigo,
SUM(CASE WHEN signo = '+' THEN importe ELSE 0 END) cargo,
SUM(CASE WHEN signo = '-' THEN importe ELSE 0 END) abono,
SUM(CASE WHEN signo = '+' THEN import ELSE 0 END) - SUM(CASE WHEN signo = '-' THEN importe ELSE 0 END) saldo
FROM tabla
group by codigo