How would you use SQL window functions to calculate a rolling 7-day average of patient visits by clinic for Remedy Partners’ analytics?
Use the supplied clinic and visit data. Include participating clinics and every calendar date from the earliest to latest visit date.
clinic_id, clinic_name, visit_date, daily_visits, and rolling_7_day_avg.clinic_id, then visit_date.| Column | Type | Description |
|---|---|---|
| clinic_idPK | INT | Unique clinic identifier |
| clinic_name | VARCHAR(100) | Clinic display name |
| Column | Type | Description |
|---|---|---|
| visit_idPK | INT | Unique visit identifier |
| clinic_id | INT | Clinic associated with the visit |
| patient_id | INT | Patient associated with the visit |
| visit_date | DATE | Date of the patient visit |
| visit_type | VARCHAR(50) | Type of clinical visit |