Q&A for ebook publishers and readers
declare @UserCount decimal(18,4) declare @UserRep bigint declare @TopUsers decimal(18,4) select @UserRep = reputation from users where Id = ##userid## select @UserCount = count(1) from users where reputation > 1 select @TopUsers = count(1) from users where reputation >= @UserRep select cast((@TopUsers/@UserCount)*100 as decimal(18,4)) UserPercentile