までの時間を算出するSQL SELECT "operator_name", "log_date", "operatability", "total_elapsed_time" FROM (SELECT operator_name, date(created_at) AS log_date, operatability, sum(elapsed_time) AS total_elapsed_time FROM (SELECT operator_name, created_at, lag(operatability) over(partition by operator_name, date(created_at) COALESCE(date_diff('minute', lag(created_at) over(partition by ORDER BY created_at), created_at), 0) AS elapsed_time FROM nurikae.operatability_histories ORDER BY created_at asc) AS elapsed_time_relation WHERE operatability is NOT NULL GROUP BY operator_name, date(created_at),operatability ORDER BY log_date, operatability asc) AS "operator elapsed time query"