Windows II — frames & running
Exercise · SQL & Querying

Predict, then run it

Predict the output

visits(d, n) = (1,10),(2,20),(3,30),(4,40). A 3-day moving average, with a partial flag for the warm-up rows (frame holds < 3 rows):

SELECT d, AVG(n) OVER w AS avg3, (COUNT(*) OVER w < 3) AS partial FROM visits WINDOW w AS (ORDER BY d ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) ORDER BY d;

Predict the exact output.