It is 1 based on this SEDE query
-- http://stackoverflow.com/a/7227860/578411
select avg(reputation) median from
(select reputation,
rnasc = row_number() over(order by reputation),
rndesc = row_number() over(order by reputation desc)
from [users]
) b
where rnasc between rndesc - 1 and rndesc + 1
... which is a big lie. The actual median is...
92
As indicated by @Dronehinge the users that really should have been deleted shouldn't be part of the population.
Those registered user deletion rules are:
- The user has not visited Stack Overflow in six months
- The user has only 1 reputation,
- no visible posts,
- and no other accounts on the network
The last requirement turns the new version of the query into a multi-database beast, with temp tables and database cursors:
-- all databases
declare db_c cursor for select [name]
from sys.databases
where database_id > 5 -- skip master, temp, model, msdb, Data.SE
and database_id <> db_id() -- skip current db as well
declare @db_c_name sysname -- holds name of db after fetch
declare @sql nvarchar(max) -- holds build up sql string
-- result table
create table #all_accounts ( accountid int)
-- create a union of all accountid's across
-- all databases
set @sql = N'insert into #all_accounts '
open db_c
fetch next from db_c into @db_c_name
while(@@FETCH_STATUS = 0)
begin
set @sql = @sql + N'select accountid from ' + QUOTENAME(@db_c_name) + N'.dbo.users'
fetch next from db_c into @db_c_name
IF (@@FETCH_STATUS = 0)
BEGIN
set @sql = @sql + N'
union
'
END
end
close db_c
deallocate db_c
print @sql
exec(@sql) -- execute the insert with the unions
-- http://stackoverflow.com/a/7227860/578411
select avg(reputation) median from
(select u.reputation,
rnasc = row_number() over(order by u.reputation),
rndesc = row_number() over(order by u.reputation desc)
from [users] u
-- https://meta.stackexchange.com/questions/146450/delete-old-unloved-users/146452#146452
where u.lastaccessdate > dateadd(m, -6, getdate()) -- active in last 6 months ago
and u.reputation > 1 -- more then 1 rep
and exists (select 1 from posts where owneruserid = u.id) -- visible post
and exists (select 1 from #all_accounts where accountid = u.accountid) --other accounts in the network
) b
where rnasc between rndesc - 1 and rndesc + 1
select count(*)
from #all_accounts
select count(*)
from users
select count(*)
from users u
left outer join #all_accounts acc on acc.accountid = u.accountid
where acc.accountid is null
drop table #all_accounts
SELECT MAX(Reputation) FROM (SELECT TOP 50 percent Reputation FROM Users ORDER BY Reputation) as halfbyrep
says it is 1. Add aWHERE
clause to narrow down the selection of what users 'count'.GROUP BY year(user.CreationDate)
or byuser.LastAccessDate
to see if any intrayear trends pop up?