tested running for a month
This commit is contained in:
12
get_latest_from_db.txt
Normal file
12
get_latest_from_db.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# Retrieve the last value for building_total
|
||||
sqlite3 power_data.db "SELECT * FROM building_totals ORDER BY timestamp DESC LIMIT 1;"
|
||||
|
||||
# Retrieve the last value for each individual record in room_breakdown
|
||||
sqlite3 power_data.db "
|
||||
SELECT r1.*
|
||||
FROM room_breakdown r1
|
||||
INNER JOIN (
|
||||
SELECT room_number, MAX(timestamp) AS max_timestamp
|
||||
FROM room_breakdown
|
||||
GROUP BY room_number
|
||||
) r2 ON r1.room_number = r2.room_number AND r1.timestamp = r2.max_timestamp;"
|
||||
Reference in New Issue
Block a user