Ver originalSELECT *FROM(SELECT r.fecha,IF(r.tipo='RELLENO',r.litros,NULL) AS RELLENO,IF(c.tipo='CAMBIO',c.litros,NULL) AS CAMBIOFROM aceites AS cLEFT JOIN aceites AS r ON r.fecha = c.fechaORDER BY fecha, CAMBIO DESC) AS tWHERE (CAMBIO IS NOT NULL OR RELLENO IS NOT NULL)GROUP BY fecha