Having a table T like this:
ID DateTime asha
AF35 15-01-17 af
AF35 14-01-17 la
AF35 13-01-17 fi
DF57 15-01-17 sk
DF57 14-01-17 sj
DG36 15-01-17 be
DG36 14-01-17 dh
What is the simplest mysql
query to have only first row for each unique ID
returned, being ordered by the most recent DateTime
?
I the expected result would be something like this:
ID DateTime asha
AF35 15-01-17 af
DF57 15-01-17 sk
DG36 15-01-17 be
I tried SELECT * FROM T GROUP BY ID ORDER BY DateTime
, however, mysql returns an error for not adding the other columns to the clause. And if I add them, I still get duplicated results for the ID.