Optum interview question

reverse an array, Group by sql