how to remove duplicate in sql
snippet in sql

delete duplicates with sql

user535

WITH cte AS (
    SELECT 
        *, 
        ROW_NUMBER() OVER (
            PARTITION BY 
                Name,
                Age
            ORDER BY 
                Name,
                Age
        ) row_num
     FROM 
        TableName
)
delete FROM cte
WHERE row_num > 1;

how to remove duplicate in sql

user5091

Distinct: helps to remove all the duplicate
records when retrieving the records from a table.

SELECT DISTINCT FIRST_NAME FROM VISITORS;

query delete duplicates

user9775

DELETE FROM dups a USING (
      SELECT MIN(ctid) as ctid, key
        FROM dups 
        GROUP BY key HAVING COUNT(*) > 1
      ) b
      WHERE a.key = b.key 
      AND a.ctid <> b.ctid