StackOverflow Rank and Percentile

0

Please login or register to vote for this query.

(click on this box to dismiss)

MinReputation: base percentile calculation on users with a reputation of MinReputation or more. UserId: The user id, e.g. 7017466 Results: Id: UserId Ranking: position in the ranking, the lower the better Percentile: expressed 0-100 TotalUsers: Total users with MinReputation or more

Craft CMS

Q&A for administrators, end users, developers and designers for Craft CMS

-- 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 >= ##MinReputation##
)
SELECT Id, Ranking
  , ROUND(
      CAST(Ranking AS decimal(20, 5)) * 100 / (SELECT Count FROM Counts)
      ,2) AS Percentile
  , (SELECT Count FROM Counts) AS TotalUsers
FROM Rankings
WHERE Id = ##UserId##

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results