Your question is SQL Cohort and Timeline Query. Start with the requirements and the three 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.
Dana-Farber Cancer Institute's clinical analytics team is reviewing whether patients developed a specified condition after receiving a particular treatment.
Write a PostgreSQL query to find every qualifying Treatment A and Condition B event pair. A diagnosis qualifies only when it occurs after Treatment A and no later than six calendar months after that treatment.
patient_id.Treatment A and diagnoses to Condition B.| Column | Type | Description |
|---|---|---|
| patient_idPK | INTEGER | Unique patient identifier |
| patient_name | VARCHAR(100) | Patient's display name |
| Column | Type | Description |
|---|---|---|
| treatment_idPK | INTEGER | Unique treatment record identifier |
| patient_id | INTEGER | Patient receiving the treatment |
| treatment_name | VARCHAR(100) | Name of the treatment administered |
| treatment_date | DATE | Date the treatment was administered |
| Column | Type | Description |
|---|---|---|
| diagnosis_idPK | INTEGER | Unique diagnosis record identifier |
| patient_id | INTEGER | Patient receiving the diagnosis |
| condition_name | VARCHAR(100) | Name of the diagnosed condition |
| condition_date | DATE | Date the condition was diagnosed |