I have a table where I store device id's, message, date, and time.
I am able to query and get all the records without any problem, however, what I want to do is to just get the latest message from each device. So for example, my database would look like:
device id msg date time
Device 0 -- Message 0 -- 2016 - 05 - 22 -- 08:00:00
Device 1 -- Message 1 -- 2016 - 05 - 22 -- 09:00:00
Device 0 -- Message 2 -- 2016 - 05 - 23 -- 10:00:00
Device 1 -- Message 3 -- 2016 - 05 - 23 -- 11:00:00
Device 0 -- Message 4 -- 2016 - 05 - 24 -- 17:00:00
Device 1 -- Message 5 -- 2016 - 05 - 24 -- 16:00:00
And I want the result to be:
Device 0 -- Message 4 -- 2016 - 05 - 24 -- 17:00:00
Device 1 -- Message 5 -- 2016 - 05 - 24 -- 16:00:00
So far I could only sort by one column, whenever I try filtering through 2 columns at the same time using a join or a select within a select, I couldn't seem to make it work.