Interview practice question
Seven-day moving average
Data Engineering · SQL · Intermediate
Calculate a 7-day moving average of daily active users.
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Build daily counts first, with a date spine for missing days.
- Use AVG over ROWS BETWEEN 6 PRECEDING AND CURRENT ROW.
- ROWS counts rows, so missing days would distort it without a spine.
- First six days have partial windows.
- Can use RANGE with intervals in engines that support it.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.