Sorry for the ambiguous title; but I don't now how to describe it different.
I have the following table:
imei | date | time | some more fields
345 | 2012-06-28 | 07:18 | .....
345 | 2012-06-28 | 07:20 | .....
345 | 2012-06-28 | 07:21 | .....
987 | 2012-06-28 | 07:19 | .....
etc etc
I want to get the latest row of ervery distinct imei, so:
345 | 2012-06-28 | 07:21
987 | 2012-06-28 | 07:19
- Using
SELECT * FROM t GROUP BY imei
results in using the first line instead of the last one. - Ordering by
time
obviously orders the result relation instead of the sub. - Using having is only for stating a condition....
How can I write a query to do this?