I have duplicate data in a single table.
Table Layout
accountNumber | firstName | lastName | address | zip
SMI2365894511 | Paul | Smith | 1245 Rd | 89120
SMI2365894511 | Paul | Smith | |
I have the below query to find and display the duplicates.
select *
from tableA a
join (select accountNumber
from tableA
group by accountNumber
having count(*) > 1 ) b
on a.accountNumber = b.accountNumber
What I would like to do is compare the results of the above query and remove the duplicate that doesn't have any address information. I'm using MS SQL Server 2014
EDIT** I have the query the way it is so can see both duplicate rows