I have a table with many duplicate records . My table looks like this:
ID |First_Name | Last_Name |City
1 | Alan | Smith |Los Angeles
2 | Alan | Smith |
3 | Alan | Smith |New York
4 | Alan | Smith |
5 | Alan | Smith |Houston
I can find duplicate records with this query:
SELECT First_Name, Last_Name, COUNT(*)
FROM tab_Name
GROUP BY First_Name, Last_Name
HAVING COUNT(*) > 1
I'd like to remove duplicate records only under following 2 conditions:
- The First_Name and Last_Name are the same
- the city column is empty(null).
What's the correct way to achieve this? Please let me know if more explanation is needed. Thank you!
(15, 'John', 'Doe', null)and(16, 'John', 'Doe', null)? Would you delete both of them? None? One? Which one?