Exercise · SQL & Querying
Predict, then run it
Predict the output
pings(t) = 0, 30 (minutes), with a 30-minute timeout. If an exactly-30-minute gap should keep the pings in one session, the boundary operator is '>':
SELECT SUM(CASE WHEN gap > 30 THEN 1 ELSE 0 END) AS new_sessions FROM (SELECT t - LAG(t) OVER (ORDER BY t) AS gap FROM pings) WHERE gap IS NOT NULL;
Predict the exact output.