Write a SQL query to find duplicate patient records across two separate clinical trial databases.
Treat records as duplicates when first name, last name, and date of birth match after trimming whitespace and ignoring letter case. Return each matching record pair, including the source patient IDs and email addresses.
trial_a_patient_id, trial_b_patient_id, normalized_first_name, normalized_last_name, date_of_birth, trial_a_email, trial_b_email| Column | Type | Description |
|---|---|---|
| patient_idPK | INT | Patient identifier in clinical trial database A |
| first_name | VARCHAR(100) | Patient first name |
| last_name | VARCHAR(100) | Patient last name |
| date_of_birth | DATE | Patient date of birth |
| VARCHAR(255) | Patient email address |
| Column | Type | Description |
|---|---|---|
| patient_idPK | INT | Patient identifier in clinical trial database B |
| first_name | VARCHAR(100) | Patient first name |
| last_name | VARCHAR(100) | Patient last name |
| date_of_birth | DATE | Patient date of birth |
| VARCHAR(255) | Patient email address |