I just want to filter few columns from the table according to MAX(ts)
. ts = timestamp
. And everything is OK if I select only two columns - deviceid and ts:
SELECT deviceid, MAX(ts)
FROM device_data
GROUP BY deviceid
and the result:
but I also need two columns more - longitude and lattitude. I have the problem if I select longitude and lattitude because they have to appear in GROUP BY and I get too much results with the same deviceid:
How can I avoid inserting longitude and lattitude in GROUP BY?