Skip to content

Instantly share code, notes, and snippets.

@J2112O
Created October 12, 2022 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save J2112O/57c6ffe46410ba09f4330bc85344ed0b to your computer and use it in GitHub Desktop.
Save J2112O/57c6ffe46410ba09f4330bc85344ed0b to your computer and use it in GitHub Desktop.
SELECT t.id, t.start_segment, t.end_segment,
SUM(t.one_lag) OVER(ORDER BY t.id ASC) AS rolling_sum
FROM
(SELECT
id, start_segment, end_segment,
IFNULL(LAG(segment_length, 1) OVER(ORDER BY id ASC), 0) AS one_lag
FROM coords_measure) AS t;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment