Write a query using window functions such as ROW_NUMBER() or DENSE_RANK() to identify duplicate patient records in a clinical dataset.
Use matching first name, last name, date of birth, and phone number to define duplicates. Return records after the earliest record in each duplicate group.
patient_record_id, source_name, patient identifying fields, duplicate_sequence, and duplicate_count.| Column | Type | Description |
|---|---|---|
| patient_record_idPK | INT | Unique clinical patient record identifier |
| source_id | INT | Originating data source identifier |
| first_name | VARCHAR(100) | Patient first name |
| last_name | VARCHAR(100) | Patient last name |
| date_of_birth | DATE | Patient date of birth |
| phone | VARCHAR(25) | Patient telephone number |
| created_at | TIMESTAMP | Timestamp when the source record was created |
| Column | Type | Description |
|---|---|---|
| source_idPK | INT | Unique source identifier |
| source_name | VARCHAR(100) | Name of the clinical data source |