Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
由于糟糕的数据录入政策,同一客户有很多重复的电话号码。我需要编写一个查询,列出所有具有相同电话号码的客户。
谢谢你的帮助。
;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;