update Babies set BirthOrder =tb.sn from Babies b1,
(select ROW_NUMBER() over (partition by familyid order by BirthOrder ) as sn,id,FamilyId,BirthOrder from Babies
where IsDeleted = 0
group by FamilyId,id,BirthOrder
) as tb
where b1.Id=tb.Id