Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles
-- StackOverflow Rank and Percentile WITH Rankings AS ( SELECT Id, Ranking = ROW_NUMBER() OVER(ORDER BY Reputation DESC) FROM Users ) ,Counts AS ( SELECT Count = COUNT(*) FROM Users WHERE Reputation > 1) SELECT Id, Ranking, CAST(Ranking AS decimal(10, 5)) / (SELECT Count FROM Counts) AS Percentile FROM Rankings WHERE Id = ##UserId##