Dear all,
I'm setting up a function able to inform enumerators when devices batteries run lower than 15%. I know that theses informations are stored in device_state_event table and battery level column...but i'm unable to select the newest (latest) record (reading) from this table...
Does it the select (min) or the select (max)?
Also, please can you add timestamp in this table? Or can you advise us how to link (join) this table with the ones containing timestamp?
Thanks in advance for your support!
Last device battery level (reading)
Last device battery level (reading)
G.VOLNY, a CSProuser from Haiti, since 2004
-
- Posts: 1792
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Last device battery level (reading)
The IDs increment, so you can get the latest value with this:
Every paradata event table links to the main "event" table, so you can get the timestamp and battery level with this:SELECT battery_level FROM device_state_event ORDER BY id DESC LIMIT 1;
SELECT time, battery_level FROM device_state_event JOIN event ON event.id = device_state_event.id ORDER BY event.id DESC LIMIT 1;