diff --git a/fact_daily_presence_duration/fact_daily_presence_duration.sql b/fact_daily_presence_duration/fact_daily_presence_duration.sql index 866564d..7e13566 100644 --- a/fact_daily_presence_duration/fact_daily_presence_duration.sql +++ b/fact_daily_presence_duration/fact_daily_presence_duration.sql @@ -54,8 +54,12 @@ ORDER BY device_id, event_date) select device_id, event_date, - CONCAT(FLOOR(motion_seconds / 3600), ':', LPAD(FLOOR((motion_seconds % 3600) / 60)::TEXT, 2, '0')) AS motion_formated_duration, - CONCAT(FLOOR(presence_seconds / 3600), ':', LPAD(FLOOR((presence_seconds % 3600) / 60)::TEXT, 2, '0')) AS motion_formated_duration, - CONCAT(FLOOR(none_seconds / 3600), ':', LPAD(FLOOR((none_seconds % 3600) / 60)::TEXT, 2, '0')) AS motion_formated_duration + motion_seconds, + CONCAT(FLOOR(motion_seconds / 3600), ':',LPAD(FLOOR((motion_seconds % 3600) / 60)::TEXT, 2, '0'), ':',LPAD(FLOOR(motion_seconds % 60)::TEXT, 2, '0')) AS motion_formatted_duration, + presence_seconds, + CONCAT(FLOOR(presence_seconds / 3600), ':',LPAD(FLOOR((presence_seconds % 3600) / 60)::TEXT, 2, '0'), ':',LPAD(FLOOR(presence_seconds % 60)::TEXT, 2, '0')) AS presence_formatted_duration, + none_seconds, + CONCAT(FLOOR(none_seconds / 3600), ':',LPAD(FLOOR((none_seconds % 3600) / 60)::TEXT, 2, '0'), ':',LPAD(FLOOR(none_seconds % 60)::TEXT, 2, '0')) AS none_formatted_duration from duration +order by 1,2