Dell Technologies uses Dell APEX usage analytics to evaluate engagement across customer signup cohorts. Write a PostgreSQL query that creates a daily user activity series for a fixed reporting period, calculates each user's 7-day rolling average, and ranks users within their cohort for each day.
Requirements
- Use
2025-02-01 through 2025-02-05 as the reporting period.
- Aggregate multiple usage events for the same user and day. Treat missing or NULL usage as zero.
- Include users with no usage events during the reporting period.
- Calculate a calendar-based rolling average using the current day and up to the six preceding days.
- Rank users within each signup-month cohort and activity date by rolling average descending. Ties must receive the same rank.
- Return
cohort_month, activity_date, user_id, rolling_avg_units, and cohort_rank, ordered by cohort, date, and rank.
Output details
- Include only users with non-NULL signup dates on or before
2025-02-05.
- Round
rolling_avg_units to two decimal places.
- Order by
cohort_month ascending, activity_date ascending, cohort_rank ascending, then user_id ascending.