mirror of
https://github.com/SyncrowIOT/data.git
synced 2025-07-10 15:17:24 +00:00
format
This commit is contained in:
@ -72,12 +72,15 @@ WITH start_date AS (
|
||||
t.space_id,
|
||||
DATE(t.start_time) AS occupancy_date,
|
||||
GREATEST(0, LEAST(86400, SUM(EXTRACT(EPOCH FROM (t.end_time - t.start_time))) -
|
||||
COALESCE(SUM(e.missing_seconds), 0))) AS total_presence_seconds
|
||||
COALESCE(SUM(e.missing_seconds), 0))) AS total_presence_seconds,
|
||||
TO_CHAR(INTERVAL '1 second' * GREATEST(0, LEAST(86400, SUM(EXTRACT(EPOCH FROM (t.end_time - t.start_time))) -
|
||||
COALESCE(SUM(e.missing_seconds), 0))), 'HH24:MI:SS') AS total_presence_duration
|
||||
FROM time_intervals t
|
||||
LEFT JOIN expanded_overlapping_none_presence e
|
||||
ON t.space_id = e.space_id
|
||||
AND DATE(t.start_time) = e.missing_date
|
||||
GROUP BY t.space_id, DATE(t.start_time)
|
||||
order by 1,2
|
||||
)
|
||||
|
||||
SELECT * FROM daily_total_occupancy;
|
||||
|
Reference in New Issue
Block a user