Because of poor data entry policies, there are a lot of duplicate phone numbers to the same customers. I need to write a query that will list all customers with the same phone number.
Thanks for your help.
Because of poor data entry policies, there are a lot of duplicate phone numbers to the same customers. I need to write a query that will list all customers with the same phone number.
Thanks for your help.
;WITH dupes AS
(
SELECT Phone_Number
FROM dbo.Customer_Table
GROUP BY Phone_Number
HAVING COUNT(*) > 1
)
SELECT c.Customer_Name, dupes.Phone_Number
FROM dupes
INNER JOIN dbo.Customer_Table AS c
ON dupes.Phone_Number = c.Phone_Number;