Created
August 20, 2013 17:39
-
-
Save jkatz/6284672 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 emails AS ( | |
SELECT e.id, split_part(e.email, '@', 1) || row_number() OVER (PARTITION BY split_part(e.email, '@', 1)) AS email | |
FROM email_addresses e | |
WHERE e.email !~ '@(domain|example).com$' AND e.email <> '' | |
) | |
UPDATE email_addresses e | |
SET email = emails.email || '@example.com' | |
FROM emails | |
WHERE e.id = emails.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment