-3

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

Shadow
  • 33,525
  • 10
  • 51
  • 64
  • ORDER BY X DESC LIMIT 2 ? People will likely ask to see the table schema, which you can get from doing query `DESCRIBE donneesgps` – Duane Lortie Nov 04 '16 at 23:44
  • Possible duplicate of [SQL Select only rows with Max Value on a Column](http://stackoverflow.com/questions/7745609/sql-select-only-rows-with-max-value-on-a-column) – Paul Spiegel Nov 04 '16 at 23:45

1 Answers1

0

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
                );
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786