Which communities has the most users in Stack Exchange?

0

Please login or register to vote for this query.

(click on this box to dismiss)

http://meta.stackexchange.com/questions/278778/which-communities-has-the-most-users-in-stack-exchang

Physics

Q&A for active researchers, academics and students of physics

-- 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 < 10
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_users ( site nvarchar(250)
                            , All_Questions int, First_questions int, Percentage float, 
                            );

open db_c
fetch next from db_c into @db_c_name
while(@@FETCH_STATUS = 0)
begin
    set @sql = N'use '+ QUOTENAME(@db_c_name) +';
    
   
   WITH FirstPosts as (
SELECT MIN(Id) AS MinId
FROM Posts
WHERE PostTypeId=1
GROUP BY OwnerUserId
), tots as (
SELECT  (
        SELECT COUNT(*)
        FROM  FirstPosts
        ) AS FirstAnswers,
        (
        SELECT COUNT(*)
        FROM   Posts
        WHERE PostTypeId=1
        ) AS Answers
        )
        
        insert into #all_users 
        SELECT '''+ QUOTENAME(@db_c_name) +''', FirstAnswers, Answers, CAST(FirstAnswers AS float)/CAST(Answers AS FLOAT) as Percentage 
from tots'
    exec (@sql)
   fetch next from db_c into @db_c_name
end;
close db_c;
deallocate db_c;

select * from #all_users-- all databases

Enter Parameters

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