开发者

Remove duplicate from different columns in SQL Server 2000

开发者 https://www.devze.com 2022-12-26 11:10 出处:网络
I ha开发者_运维知识库ve table : number city1 city2 mentions 1 a b 5 1 b a 5 1 c d 2 1 d c 2 what I need is to remove duplicate records, such as a, b equal to b,a became :

I ha开发者_运维知识库ve table :

number city1 city2 mentions
1 a b 5
1 b a 5
1 c d 2
1 d c 2

what I need is to remove duplicate records, such as a, b equal to b,a became :

number city1 city2 mentions
1 a b 5
1 c d 2

any clue for me ?

thanks before :)


Like this?

delete from table t1
where exists (
  select *
  from table t2
  where
    t2.number = t1.number and
    t2.city1 = t1.city2 and
    t2.city2 = t1.city1 and
    t2.mentions = t1.mentions and
    t2.city1 < t2.city2
)
0

精彩评论

暂无评论...
验证码 换一张
取 消