Computes what percentage of users have lower reputation than the given user ID. A minimum reputation can be specified to cut off one-time users and other such outliers. (use a large negative number to consider all users)
Q&A about the site for students, teachers, and linguists wanting to discuss the finer points of the Japanese language
declare @TotalUsers float select @TotalUsers = count(*) from Users where Reputation > ##MinReputation## declare @MyReputation int select @MyReputation = Reputation from Users where Id = ##UserId## declare @CountBelow float select @CountBelow = count(*) from Users where Reputation < @MyReputation and Reputation > ##MinReputation## select (@CountBelow / @TotalUsers) * 100 as Percentile