Running totals are common in reporting dashboards, finance, and product analytics. Interviewers ask this to test whether you understand cumulative calculations, row ordering, and when to use window functions instead of grouped aggregates.
Explain how you would compute a running total in SQL. Your answer should cover:
SUM() OVER (...) is typically the right approachORDER BY changes the resultGROUP BY with window functionsAssume the interviewer expects a practical explanation using PostgreSQL syntax, not just a definition. You should be able to describe the pattern, show a short example query, and explain edge cases like duplicate dates, partitions, and NULL values.