Explain it in 60 seconds
Running totals and window frames
Data Engineering · SQL · Intermediate
How do you calculate a running total in SQL, and what is a window frame?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Use SUM(amount) OVER (PARTITION BY ... ORDER BY date).
- The frame defines which rows are included relative to the current row.
- ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW is a classic running total.
- ROWS BETWEEN 6 PRECEDING AND CURRENT ROW gives a 7-row moving window.
- Default frame with ORDER BY is RANGE, which treats ties together.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.