The PlayStation Plus analytics team wants to monitor subscriber engagement over a ten-day period. Write a PostgreSQL query that calculates daily active users, or DAU, for PlayStation Plus subscribers and the 7-day rolling average of that DAU.
Requirements
- Count each PlayStation Plus subscriber at most once per calendar day, even if they generate multiple activity events.
- Include calendar dates with zero qualifying activity so the rolling window represents seven consecutive days.
- Treat a user as a subscriber only when the activity date falls between their subscription start and end dates, inclusively.
- Return the date, daily DAU, and rolling average rounded to two decimal places. For the first six dates, calculate the average over the available dates.
Output details
- Use the inclusive date range from
2025-01-01 through 2025-01-10.
- Return columns named
activity_date, daily_dau, and rolling_7_day_avg, in that order.
- Sort results by
activity_date ascending.