Find duplicates in SQL

前端 未结 2 1944
说谎
说谎 2020-12-16 18:29

I have a large table with the following data on users.

social security number
name
address

I want to find all possible duplicates in the ta

2条回答
  •  佛祖请我去吃肉
    2020-12-16 19:06

    This will handle more than two records with duplicate ssn's:

    select count(*), name from table t1, (    
        select count(*) ssn_count, ssn 
        from table 
        group by ssn 
        having count(*) > 1
    ) t2
    where t1.ssn = t2.ssn
    group by t1.name
    having count(*) <> t2.ssn_count
    

提交回复
热议问题