Write a SQL query using SQL window functions to calculate rolling thirty-day active user averages across multiple regional patient registries.
Use the supplied registry, patient, and activity data. Include every registry for every calendar date in the activity range, treating dates without activity as zero active users.
Output
- One row per registry and calendar date, including registries with no activity.
- Columns:
registry_id, registry_name, region_code, activity_date, active_users, and rolling_30_day_average.
- Count distinct active patients with activity on each date. Order by
registry_id, then activity_date.