Finding duplicate values in a SQL table

后端 未结 30 4004
南旧
南旧 2020-11-21 13:18

It\'s easy to find duplicates with one field:

SELECT name, COUNT(email) 
FROM users
GROUP BY email
HAVING COUNT(email) > 1

So if we have

30条回答
  •  既然无缘
    2020-11-21 13:48

    Try the following:

    SELECT * FROM
    (
        SELECT Id, Name, Age, Comments, Row_Number() OVER(PARTITION BY Name, Age ORDER By Name)
            AS Rank 
            FROM Customers
    ) AS B WHERE Rank>1
    

提交回复
热议问题