Optum Interview Question

reverse an array, Group by sql