4:43 PM
@MartinSmith nice idea, why did you delete the answer?
I mean about the random GroupID sorting
You could use FIRST_VALUE(<random_function>) OVER (PARTITION BY GroupID ORDER BY SomeValue)
to remove the group size effect
Or the ROW()_NUMBER() .. = 1 you already posted. Seems better and works in older versions.