1

您好我有一个匹配应用程序,它使用 Jaro 算法匹配两个字段。

如何删除以下内容:请参阅下面的图片链接以了解我的问题 :)

http://www2.picturepush.com/photo/a/13121095/640/13121095.jpg

谢谢

4

1 回答 1

1

假设“保持与 str1 的最高匹配的行”那么这个

DECLARE @t TABLE (str1 varchar(50), str2 varchar(50), MATCH decimal (5,2));
INSERT @t VALUES 
        ('ABC ELEC', 'ABC ELEC', 100),  ('ABC ELEC', 'ABB ELEC', 95), 
        ('ABC ELEC', 'ABC ELEK', 92.5), ('ABC ELEC', 'ABF ELEC', 91.5), 
        ('ABC ELEC', 'ADD ELEK', 95.5), ('BBC INVEST', 'BBC DOMEST ELEC', 85.94);

DELETE X
FROM
    (
    SELECT
       str1, str2,
       ROW_NUMBER() OVER (PARTITION BY T.str1 ORDER BY T.MATCH DESC) AS rn
    FROM
        @t T
    ) X
WHERE rn > 1;

SELECT * FROM @t T;
于 2013-05-21T08:00:58.720 回答