Prova così
codice:
select partita,sum(if(colonna="D",+importo_totale,-importo_totale)) as attivo
from cliestco
group by partita
having attivo > 0