-5

由于糟糕的数据录入政策,同一客户有很多重复的电话号码。我需要编写一个查询,列出所有具有相同电话号码的客户。

谢谢你的帮助。

4

1 回答 1

4
;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;
于 2013-03-06T21:21:15.280 回答