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 for those who study, teach, research and apply economics and econometrics
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