Created
November 20, 2017 09:32
-
-
Save jaderabbit/5b4cdd1ba6128bbd5dd15dc496e03af1 to your computer and use it in GitHub Desktop.
Deleting Dups Postgresql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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