Your question is Rolling Retention Rates Across Sites. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Verily Baseline study operations need to compare patient retention across clinical sites. A patient is retained for a visit date if the same patient has another visit at the same site within the following 30 calendar days.
Write a PostgreSQL query that calculates rolling 30-day retention by site and active visit date.
| Column | Type | Description |
|---|---|---|
| site_idPK | INTEGER | Clinical site identifier |
| site_name | VARCHAR(100) | Clinical site name |
| region | VARCHAR(50) | Geographic region of the site |
| Column | Type | Description |
|---|---|---|
| visit_idPK | INTEGER | Unique visit identifier |
| site_id | INTEGER | Site where the visit occurred |
| patient_id | INTEGER | Patient identifier |
| visit_date | DATE | Date of the patient visit |