DataDesk
All topics
Window functions: LAG, LEAD & running totals — practice · DataDesk
DataDesk
How it works
Scenarios
Practice
For trainers
Pricing
Log in
Start free
SQL
Window functions: LAG, LEAD & running totals
Compare rows and accumulate values.
0
/ 20 solved
All levels
Basic (5)
Intermediate (7)
Advanced (8)
All
To do
Solved
1
Running total
Basic
2
Previous month with LAG
Basic
3
Next month with LEAD
Basic
4
Running total per group
Basic
5
Total next to each row
Basic
6
Month-over-month change
Interview
Intermediate
7
3-month moving average
Interview
Intermediate
8
Share of region total
Intermediate
9
Account balance
Interview
Intermediate
10
First and last value
Intermediate
11
Months with a drop
Intermediate
12
Days since previous login
Intermediate
13
Running total that resets each month
Advanced
14
Year-to-date vs previous month
Advanced
15
Growth streaks
Interview
Advanced
16
Largest single-day balance drop
Advanced
17
Rolling 7-day active users
Advanced
18
Cumulative share (Pareto)
Interview
Advanced
19
Compare with same month average
Advanced
20
Sessions from logins
Interview
Advanced