I have a table similar to below (PatientData
)
| id_number | phone | email | dob |
| -- | ---------- | ---- | ---- |
| 6 | 04-------61 | example@gmail.com| 196949200 |
| 5 | 04-------61 | example@gmail.com| 296949200 |
| 4 | 55-------51 | example@gmail.com| 396949200 |
| 3 | 04-------61 | test@gmail.com | 496949200 |
| 2 | 66-------61 | test@gmail.com | 596949200 |
| 1 | 77-------61 | another@gmail.com| 696949200 |
I want to get rows that have a distinct 'phone' and 'email' (not a distinct combination) along with the data associated with the first instance (here dob as an example).
My desired output:
| id_number | phone | email | dob |
| -- | ---------- | ---- | ---- |
| 6 | 04-------61 | example@gmail.com| 196949200 |
| 2 | 66-------61 | test@gmail.com | 596949200 |
| 1 | 77-------61 | another@gmail.com| 696949200 |
Is there a way I can achieve this? I've tried using distinct and group by but I can't see how they would be helpful in this case.