Q&A for people looking to bypass life's everyday problems with simple tricks
-- 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 > 100 ) SELECT Id, Ranking, Counts.[Count] As Num, CAST(Ranking AS decimal(10, 5)) / (SELECT Count FROM Counts) AS Percentile FROM Rankings, Counts WHERE Id = ##UserId##