Created
April 28, 2019 00:57
-
-
Save evervasquez/b7c904f7e5573dfdc08c38ec15d96827 to your computer and use it in GitHub Desktop.
Eliminate duplicate records
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
WITH tableunica AS | |
(SELECT table1.id, min(ctid) | |
FROM table1 | |
GROUP BY 1 HAVING count(*) > 1) | |
DELETE FROM table1 | |
USING tableunica | |
WHERE (table1.id)=(tableunica.id) | |
AND table1.ctid <> tableunica.min |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment