Ver originalSELECT id, SUM(IF(TIPO='abono', vañlor, 0)) abono, SUM(IF(TIPO='entrada', valor, 0)) entradaFROM mitabla GROUP BY id