Created
May 24, 2019 15:32
-
-
Save dncpax/df64dd4fc67f1d846ba10e5a6d3ec335 to your computer and use it in GitHub Desktop.
postgresql - find duplicates
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
select * from ( | |
SELECT id, | |
ROW_NUMBER() OVER(PARTITION BY column1, column2 ORDER BY id asc) AS Row | |
FROM tbl | |
) dups | |
where | |
dups.Row > 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another possibility I like:
Simple to read and remember...
original here: https://stackoverflow.com/questions/50805439/postgresql-fastest-way-to-get-duplicates