Nice Article. I learned a lot. But for this problem there may be a shorter/ simpler solution :
--======1 Insert Records We want to have
Insert into SOURCE(Name, Age, Sex)
Select Name
, Age
, Case Sex When 'M' Then 'N' Else 'G' End
From SOURCE
Group By Name, Age, Sex
Having Count (*) > 1
--======2: Remove the old rows
Delete from SOURCE
Where Sex In ('M','F')
--======3: Update the inserted records accordingly
Update SOURCE
Set Sex = CASE Sex When 'N' Then 'M' Else 'F' End
Both of us depend on the case that Sex column has one of two values. If that is not the case then solution would be appending a character / string that does not exist in the original data (ex '~~~~~') in first step. Delete the ones that does not have appended string in the second step. Remove appended string in the third step.