KilnVM Live Labs /lab/duckdb-window-functions-lab
Step 1 of 3 Docs Build Your Own

DuckDB SQL Window Functions and Parquet Export

Compute running totals with SUM() OVER, detect traffic spikes via LAG(), and export aggregated tables to Parquet using DuckDB.

Step 1 of 3

Compute partitioned running totals

Use SUM(requests) OVER (PARTITION BY region ORDER BY day) against /workspace/daily_usage.csv and save the CSV output to running_totals.csv:

bash
duckdb -csv -c "SELECT day, region, requests, SUM(requests) OVER (PARTITION BY region ORDER BY day) AS running_total FROM 'daily_usage.csv' ORDER BY region, day;" > running_totals.csv && cat running_totals.csv

Click Check Step once verified.