Skip to content

Instantly share code, notes, and snippets.

@jaderabbit
Created November 20, 2017 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaderabbit/5b4cdd1ba6128bbd5dd15dc496e03af1 to your computer and use it in GitHub Desktop.
Save jaderabbit/5b4cdd1ba6128bbd5dd15dc496e03af1 to your computer and use it in GitHub Desktop.
Deleting Dups Postgresql
DELETE FROM tablename
WHERE id IN (
SELECT id
FROM (SELECT id,
ROW_NUMBER() OVER (partition BY column1, column2, column3 ORDER BY id) AS rnum
FROM tablename) t
WHERE t.rnum > 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment