Problems / Session Metrics Rollup / Editorial
LAG(event_time)
> 1800
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
GROUP BY user_id, session_seq
MIN
session_start
COUNT(*)
MAX - MIN
0.00
Sessionization is the canonical flag-then-prefix-sum pattern: a *local* judgment (this row starts something new, via LAG) is converted into a *global* grouping key by a running sum. Once you see that two-step shape, dozens of "segment the sequence" problems — streaks, shifts, outage windows — reduce to the same skeleton, and everything after it is ordinary GROUP BY arithmetic.
Solve Session Metrics Rollup yourself →