Can you explain a time you had to clean a messy dataset before it could be used for analysis?
For this SQL exercise, clean the raw encounter records and retain only valid encounters for active patients. Standardize the date, encounter type, and status, and keep the most recently ingested record for duplicate patient-date-type combinations.
raw_id, patient_id, canonical_name, encounter_date, encounter_type, and encounter_status.patient_id, encounter_date, encounter_type, and raw_id ascending.| Column | Type | Description |
|---|---|---|
| raw_idPK | INT | Identifier for the raw encounter record |
| patient_id | VARCHAR(20) | Raw patient identifier |
| patient_name_raw | VARCHAR(150) | Patient name as received in the raw data |
| encounter_date_raw | VARCHAR(20) | Encounter date in an inconsistent text format |
| encounter_type_raw | VARCHAR(50) | Unstandardized encounter type |
| status_raw | VARCHAR(50) | Unstandardized encounter status |
| ingested_at | TIMESTAMP | Timestamp when the raw record was ingested |
| Column | Type | Description |
|---|---|---|
| patient_idPK | VARCHAR(20) | Trusted patient identifier |
| canonical_name | VARCHAR(150) | Standardized patient name |
| active | BOOLEAN | Whether the patient is currently active |