Created
March 19, 2013 02:28
-
-
Save markmo/5193259 to your computer and use it in GitHub Desktop.
Recreate dups
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
INSERT INTO X (...) | |
SELECT ... | |
FROM ( | |
SELECT <group by keys>, COUNT(*) - 1 AS K | |
FROM <table with dups> | |
WHERE ... | |
GROUP BY <group by keys> | |
HAVING COUNT(*) > 1 | |
) A | |
JOIN Tally on Tally.N <= A.K |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment