The query I’m editing is here:
select avg(reputation), count(*) from users
Number of users: 4,042,562. Mean reputation: 125.
Quartiles of reputation: 1, 1, 11, 759,633
with tmp as (
select reputation, qt=NTILE(4) over (order by reputation),
rn=ROW_NUMBER() over (order by reputation)
from users)
select reputation
from tmp
where rn in (select max(rn) from tmp group by qt)
Check it with the numbers (should be about a quarter of observations in each chunk, cumulative): 1,010,641, 2,021,282, 3,031,922, 4,042,562. Query below:
with tmp as (
select reputation, qt=NTILE(4) over (order by reputation),
rn=ROW_NUMBER() over (order by reputation)
from users)
select max(rn) from tmp group by qt
So now find quartiles of reputation for users within the top quartile overall: 23, 51, 164, 759,633. Query below:
with tmp as (
select reputation, qt=NTILE(4) over (order by reputation),
rn=ROW_NUMBER() over (order by reputation)
from users where reputation > 11)
select reputation
from tmp
where rn in (select max(rn) from tmp group by qt)
And check again the total counts within each quartile: 250,011, 500,022, 750,033, 1,000,043. Query below:
with tmp as (
select reputation, qt=NTILE(4) over (order by reputation),
rn=ROW_NUMBER() over (order by reputation)
from users where reputation > 11)
select max(rn) from tmp group by qt
So, if your reputation is higher than 164 you are among the top 1/16 users of StackOverflow: a select group of 250,010 people worldwide.