在SQL Server 2008中查找重复的值

时间:2014-11-18 13:02:45

标签: sql-server sql-server-2008 distinct

Address(COLUMN NAME)
100 INDONIA DR  CAMP ROAD 600618
100 INDONIA  CAMP ROAD 600618
1009 CLARK STREET  STEFEN ROAD 876257
1009 S MAIN ST  HOLAN 654636
1007 OAKIRA ST  FARAL DELLS 600106
1007 OAKIRA STREET  FARAL DELLS 600106
19 SUN MARTIN ST  BELGIN 122010
145 CHARLES ST  JHARVAND 110012
1007 S SUPERIOR ST.  BILTON 625017
1007 S. SUPERIOR STREET  BILTON 625017
187 HOWARD STREET  VIRLITIN 220120

我需要了解如何为此专栏制作独特的内容。值是相同的地址,但拼写在某些行中是不同的。

Address
100 INDONIA DR  CAMP ROAD 600618
100 INDONIA  CAMP ROAD 600618
1009 CLARK STREET  STEFEN ROAD 876257
1009 S MAIN ST  HOLAN 654636
1007 OAKIRA ST  FARAL DELLS 600106
1007 OAKIRA STREET  FARAL DELLS 600106
19 SUN MARTIN ST  BELGIN 122010
145 CHARLES ST  JHARVAND 110012
1007 S SUPERIOR ST.  BILTON 625017
1007 S. SUPERIOR STREET  BILTON 625017
187 HOWARD STREET  VIRLITIN 220120

这是我的尝试。

SELECT DISTINCT Ltrim(Rtrim([Address])) AS Address
FROM   [Vigness].[dbo].[Test]
WHERE  Address LIKE '% %'
       AND Len(Address) > 0
ORDER  BY 1 

1 个答案:

答案 0 :(得分:0)

这里有一个类似的问题,关于在SQL Server中使用soundex进行地址标准化

SQL address data is messy, how to clean it up in a query?

相关功能为soundex()

http://msdn.microsoft.com/en-us/library/ms187384(v=sql.100).aspx