Last active
December 19, 2017 16:47
-
-
Save paradigm314/e9ddfaa18bd23e1d22e41b22abe4923b to your computer and use it in GitHub Desktop.
Remove Duplicates Postgres
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
/* Single Key Filter */ | |
SELECT * FROM users | |
WHERE id IN (SELECT id | |
FROM (SELECT id, ROW_NUMBER() | |
OVER (PARTITION BY email ORDER BY id) AS rnum | |
FROM users) t | |
WHERE t.rnum > 1); | |
/* Multi Key Fileter */ | |
SELECT * FROM theme_files | |
WHERE id IN (SELECT id | |
FROM (SELECT id, kind, ROW_NUMBER() | |
OVER (PARTITION BY theme_id, kind ORDER BY id) AS rnum | |
FROM theme_files) t | |
WHERE t.rnum > 1 AND t.kind = 'mobile_stylesheet'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment