Created
May 30, 2015 12:21
-
-
Save reyjrar/9cc73b69881f7eb6915b to your computer and use it in GitHub Desktop.
Deletion with Aggregated Data
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 dups AS( | |
select response_id, answer_id, section | |
from meta_answer | |
group by response_id, answer_id, section | |
having count(1) > 1 | |
) | |
DELETE FROM meta_answer ma | |
WHERE EXISTS ( | |
SELECT 1 | |
FROM dups | |
WHERE dups.response_id = ma.response_id | |
AND dups.answer_id = ma.answer_id | |
AND dups.section = ma.section | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment