Windows II — frames & running
Exercise · SQL & Querying

Predict, then run it

Predict the output

runs(g, d, x) = (m,1,10),(m,2,20),(m,3,5). A running sum and running count from one named window, so they can't disagree:

SELECT d, SUM(x) OVER w AS run_sum, COUNT(*) OVER w AS run_cnt FROM runs WINDOW w AS (PARTITION BY g ORDER BY d) ORDER BY d;

Predict the exact output.