Código SQL:
Ver originalSELECT * FROM(
SELECT * FROM (
SELECT id_material,ubicacion, ISNULL(SUM(cantidad),0) AS total FROM recepcion WHERE id_material = {$id_material} ORDER BY fecha ASC GROUP BY id_material,ubicacion) t1
LEFT JOIN (SELECT MAX(fecha) max_fecha,ubicacion FROM recepcion GROUP BY recepcion) AS t2 ON (t1.ubicacion=t2.ubicacion)
) t3 ORDER BY max_fecha ASC