You could also use (Thanks to ypercubeᵀᴹ for the fix) SELECT GroupID, SomeValue FROM tablename ORDER BY FIRST_VALUE(CRYPT_GEN_RANDOM(4)) OVER (PARTITION BY GroupID ORDER BY GroupID), GroupID, --Just in case 2 groups get the same random number SomeValue; [Online demo][1] [1]: http://rextester.com/EEC78286