Skip to content

Instantly share code, notes, and snippets.

@J2112O
Created October 12, 2022 21:58
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/1cb9b6b35c72c6529ee7bbb67ba7072f to your computer and use it in GitHub Desktop.
Save J2112O/1cb9b6b35c72c6529ee7bbb67ba7072f 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,
LAG(segment_length, 1) OVER(ORDER BY id ASC) 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