Here is an example table:
ID time data type
0 0100 xyz 0
1 0200 xyz 1
2 0300 xyz 1
3 0400 xyz 2
4 0200 xyz 0
5 0500 xyz 2
6 0300 xyz 0
Data is added based on timestamp so that the last of each type has the latest time stamp.
I would like the result of a SELECT to be:
ID time data type
5 0500 xyz 2
2 0300 xyz 1
6 0300 xyz 0
And so the last of each 'type' is returned.
I can accomplish the above using three SELECT statements as follows:
SELECT time, data, type FROM table WHERE type=0 ORDER BY time DESC LIMIT 1
SELECT time, data, type FROM table WHERE type=1 ORDER BY time DESC LIMIT 1
SELECT time, data, type FROM table WHERE type=2 ORDER BY time DESC LIMIT 1
Is there a way to combine the above three SELECT statements into one?
Any help appreciated.
Chris