Running totals and LAG
Build running totals with SUM() OVER (ORDER BY ...), compare each month with the one before using LAG, and avoid the ties trap that gives two rows one total.
- The skill
- Build running totals and compare each row with the one before.
- You make
- Month-by-month revenue and customer growth for an online shop.
Premium lesson
£7.99 a month or £59 a year. Cancel any time.
Builds on 23 Window functions, ranking rows. Free to try: SQL Foundations and the playground.
Passed
You can now
Step 1 of 9
exercise_1.sql
You've reached the good stuff.
6 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.
SQLite