blugraph / bgtrans

0 stars 0 forks source link

Limit SQL query for showing recent location of all devices #3

Open jayachandranm opened 8 years ago

jayachandranm commented 8 years ago

Can be by time range, eg limit to last hour/day. If limit by number of rows, increase in number of devices can give unexpected results, missing some of the devices in effect.

jayachandranm commented 8 years ago

SELECT * FROM (

SELECT * FROM obd_gps ORDER BY TIMESTAMP DESC ) AS a GROUP BY sid

SELECT * FROM obd_gps WHERE TIMESTAMP IN (

SELECT MAX( TIMESTAMP ) FROM obd_gps GROUP BY sid )