Ver originalSELECT t1.id, t1.ref, t1.texto, t1.fecha FROM (SELECT id, ref, texto, fecha FROM tabla ORDER BY fecha DESC)t1 GROUP BY t1.ref