What i have is the following as result of a query, as you can see it has some duplicates except for the related column. What i want is to remove the duplicates while the related column gets a random value from possible values the related id has.
So something like:
id | name | related
-----+------+-----
1 | bart | 2
1 | bart | 5
1 | bart | 7
2 | john | 3
2 | john | 4
3 | mary | 2
Becomes something like:
id | name | related
-----+------+-----
1 | bart | 5
2 | john | 3
3 | mary | 2