Using row number messes up the data for some reason.You will always get the correct count. But If you do group by on random columns and take a count ,you will see a difference in count for each group. Although the sum of all group will be rqual to count .But each groups count will.vary