We Are The 99%

0

Please login or register to vote for this query.

(click on this box to dismiss)

This query aims to check the distribution of wealth (reputation-wise) of users on Stack Overflow.

Stack Overflow

Q&A for professional and enthusiast programmers

declare @TotalRep bigint
declare @UserCount bigint
declare @Top1RepTotal decimal(18,4)
declare @Bottom99RepTotal decimal(18,4)

select @TotalRep = sum(reputation) from users where reputation > 1

select @UserCount = count(1) from users where reputation > 1

select @Top1RepTotal = sum(tmp.rep) from
          (select top(1) percent reputation as rep
           from users
           where reputation > 1
           order by reputation desc) as tmp

select @Bottom99RepTotal = sum(tmp.rep) from
          (select top(99) percent reputation as rep
           from users
           where reputation > 1
           order by reputation) as tmp

select @TotalRep TotalRep,
       @UserCount UserCount,
       @Top1RepTotal Top10RepTotal,
       @Bottom99RepTotal Bottom90RepTotal,
       cast((@Top1RepTotal/@TotalRep)*100 as decimal(18,4)) Top1PercentageOfRep,
       cast((@Bottom99RepTotal/@TotalRep)*100 as decimal(18,4)) Bottom99PercentageOfRep

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results