You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kingshyg edited this page Dec 2, 2014
·
1 revision
Find unique Senses that had been uploading data in the last 2 hours, since 2014-11-01
SELECT sq.device_id, sq.id, sq.diff, sq.max_ts FROM
(SELECT M.device_id AS device_id,
MAX(M.id) AS id, MAX(D.ts) AS max_ts,
now() - MAX(D.ts) AS diff
FROM account_device_map M
LEFT OUTER JOIN device_sensors_master D ON M.id = D.device_id
WHERE D.ts > '2014-11-01 00:00:00'
GROUP BY M.device_id) AS sq
WHERE sq.diff < '2 hours';