Due to a recent bug, we have a table with multiple duplicate entries.
What I want to do is to find and ideally delete (or perhaps just update) the duplicate rows.
PersonGroup
-----------
id
personId
groupId
type
primary
value
select count(*) cnt from personGroup pg where type="FOO" group by personId having cnt > 1;
yields nearly 20k rows. There should be 0. Each personId
should have only one entry for any given type
.
I can write a program to fix this scenario but before I do that I'm wondering if there is a purely SQL solution.