SUM/COUNT/AVG OVER
Concepts covered: sqlAggregateOver
Regular SUM vs SUM OVER Running Totals: SUM OVER Here is how each row's running total is calculated: Row 1 (Jan 1): just 500, nothing before it. Row 2 (Jan 2): 500 + 300 = 800. Row 3 (Jan 3): 500 + 300 + 700 = 1,500. Row 4 (Jan 4): 500 + 300 + 700 + 200 = 1,700. Row 5 (Jan 5): 500 + 300 + 700 + 200 + 400 = 2,100. Each row accumulates all previous amounts plus its own. Running totals are perfect for cumulative revenue, inventory levels, progress toward a goal, or account balances. Any "how much so far" question is a running total use case. Grand Totals: SUM OVER () Running Calculations COUNT OVER: Running Counts AVG OVER: Cumulative Avg On day 1, the average is just 500 (only one value). On day 2, it is (500 + 300) / 2 = 400. On day 3, it is (500 + 300 + 700) / 3 = 500. On day 4, it drops t
About This Interactive Section
This section is part of the Window Functions: Beginner lesson on DataDriven, a free data engineering interview prep platform. Each section includes explanations, worked examples, and hands-on code challenges that execute in real time. SQL queries run against a live PostgreSQL database. Python runs in a sandboxed Docker container. Data modeling problems validate against interactive schema canvases. All content is framed around what data engineering interviewers actually test at companies like Meta, Google, Amazon, Netflix, Stripe, and Databricks.
How DataDriven Lessons Work
DataDriven combines four interview rounds (SQL, Python, Data Modeling, Pipeline Architecture) with adaptive difficulty and spaced repetition. Easy problems get harder as you improve. Weak concepts resurface until you master them. Your readiness score tracks progress across every topic interviewers test. Every lesson section ends with problems you solve by writing and running real code, not by picking multiple-choice answers.