find duplicates in PostgreSQL

August 21, 2021



Certain columns:

SELECT column1, column2, count(*)
FROM table
GROUP BY column1, column2
HAVING count(*) > 1

All columns:

SELECT (table.*)::text, count(*)
FROM table
GROUP BY table.*
HAVING count(*) > 1