Cyrille Belco Ier Cyrille Belco Ier - 1 month ago 11
SQL Question

Select the last entry of each group

I would like the last record in each group member. but with this application, I get rather the first two entries. I feel like Max (time) does not work

SELECT id, latitude, longitude, MAX(temps), vitesse, description, id_recepteur
FROM donneesgps
GROUP BY id_recepteur


Please help

Answer

Assuming that temps is time, you want where, not group by:

SELECT d.*
FROM donneesgps d
WHERE d.temps = (SELECT MAX(d2.temps)
                 FROM donneesgps d2
                 WHERE d2.id_recepteur = d.id_recepteur
                );