I have a table:
| personId | Date | location |
|---|---|---|
| abc123 | 15-09-2022 | London |
| abc123 | 15-09-2022 | Nottingham |
| efg321 | 12-09-2022 | Leeds |
| abc123 | 13-09-2022 | Birmingham |
I want to select and return the duplicate rows based on Date and location columns, for example, in the above table: personId 'abc123' is present at location both 'London' and 'Nottingham' on the same date, so I would like to return these rows.
I have tried this query:
SELECT personId, Date FROM sampleTable GROUP BY personId, Date HAVING COUNT(*) > 1
But it gives me the count. I want the rows with all three columns. Expected result:
| personId | Date | location |
|---|---|---|
| abc123 | 15-09-2022 | London |
| abc123 | 15-09-2022 | Nottingham |
Can anyone please help me with this? Thanks