a query to remove duplicate rows from a table code example
Example 1: how to query without duplicate rows in sql
SELECT DISTINCT col1,col2... FROM table_name where Condition;
Example 2: query delete duplicates
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