Vincente,
I didn't understand all what you said (sorry for my english !)
it's my query :
$query = "SELECT
$table.id,
DATE_FORMAT($table.date_fabrication, '%d-%m-%Y') AS date_fabrication,
$table.n_serie,
$table.industriel,
$table.mobilier,
$table.etat,
$table.zone,
$table.station,
$table.n_ligne,
DATE_FORMAT($table.date_visite, '%d-%m-%Y') AS date_visite,
$table.id_sma,
MAX($table.heure_visite) AS heure_visite,
$table.etat_affichage
FROM $table ";
$query .= "GROUP BY CONCAT(DATE_FORMAT($table.date_fabrication, '%d-%m-%Y'), $table.n_serie, $table.industriel, $table.mobilier)
ORDER BY $trier_par $ordre_tri $table.date_fabrication DESC, $table.date_visite DESC, $table.heure_visite DESC";
So if I understood you I should add at the end of my GROUP BY line :
$table.heure_visite
like that :
$query .= "GROUP BY CONCAT(DATE_FORMAT($table.date_fabrication, '%d-%m-%Y'), $table.n_serie, $table.industriel, $table.mobilier), $table.heure_visite
ORDER BY $trier_par $ordre_tri $table.date_fabrication DESC, $table.date_visite DESC, $table.heure_visite DESC";
???