Computes per user Reputation for major blocks of Reputation Points
Q&A for scientists using computers to solve scientific problems
-- Wealth Inequality by Reputation on Stack Overflow -- computes a per user reputation for 4 major blocks of reputation points select 'reputation < 10' reputationBlock ,count(*) as numUsers , sum(reputation) as totalReputation , sum(reputation)/count(*) as reputationPerUser , cast(cast(count(*) as float)/(select count(*) from Users)*100.0 as decimal(7,4)) percentOfUsers , cast(cast(sum(reputation) as float)/(select sum(reputation) from Users)*100.0 as decimal(7,4)) percentOfReputation from Users where reputation < 10 union all select 'reputation >= 10 and reputation < 100' reputationBlock ,count(*) as numUsers , sum(reputation) as totalReputation , sum(reputation)/count(*) as reputationPerUser , cast(cast(count(*) as float)/(select count(*) from Users)*100.0 as decimal(7,4)) percentOfUsers , cast(cast(sum(reputation) as float)/(select sum(reputation) from Users)*100.0 as decimal(7,4)) percentOfReputation from Users where reputation >= 10 and reputation < 100 union all select 'reputation >= 100 and reputation < 1000' reputationBlock ,count(*) as numUsers , sum(reputation) as totalReputation , sum(reputation)/count(*) as reputationPerUser , cast(cast(count(*) as float)/(select count(*) from Users)*100.0 as decimal(7,4)) percentOfUsers , cast(cast(sum(reputation) as float)/(select sum(reputation) from Users)*100.0 as decimal(7,4)) percentOfReputation from Users where reputation >= 100 and reputation < 1000 union all select 'reputation >= 1000 and reputation < 10000' reputationBlock ,count(*) as numUsers , sum(reputation) as totalReputation , sum(reputation)/count(*) as reputationPerUser , cast(cast(count(*) as float)/(select count(*) from Users)*100.0 as decimal(7,4)) percentOfUsers , cast(cast(sum(reputation) as float)/(select sum(reputation) from Users)*100.0 as decimal(7,4)) percentOfReputation from Users where reputation >= 1000 and reputation < 10000 union all select 'reputation >= 10000 and reputation < 100000' reputationBlock ,count(*) as numUsers , sum(reputation) as totalReputation , sum(reputation)/count(*) as reputationPerUser , cast(cast(count(*) as float)/(select count(*) from Users)*100.0 as decimal(7,4)) percentOfUsers , cast(cast(sum(reputation) as float)/(select sum(reputation) from Users)*100.0 as decimal(7,4)) percentOfReputation from Users where reputation >= 10000 and reputation < 100000 union all select 'reputation >= 100000 and reputation < 1000000' reputationBlock ,count(*) as numUsers , sum(reputation) as totalReputation , sum(reputation)/count(*) as reputationPerUser , cast(cast(count(*) as float)/(select count(*) from Users)*100.0 as decimal(7,4)) percentOfUsers , cast(cast(sum(reputation) as float)/(select sum(reputation) from Users)*100.0 as decimal(7,4)) percentOfReputation from Users where reputation >= 100000 and reputation < 1000000 union all select 'reputation >= 1000000' reputationBlock ,count(*) as numUsers , sum(reputation) as totalReputation , sum(reputation)/count(*) as reputationPerUser , cast(cast(count(*) as float)/(select count(*) from Users)*100.0 as decimal(7,4)) percentOfUsers , cast(cast(sum(reputation) as float)/(select sum(reputation) from Users)*100.0 as decimal(7,4)) percentOfReputation from Users where reputation >= 1000000 order by 1