Bad question ratio last quarter

1

Please login or register to vote for this query.

(click on this box to dismiss)

Health Meta

Q&A about the site for professionals in medical and allied health fields, students of those professions, related academics, and others with a sound understanding of medicine and healthcare-related sciences

create table #results(site nvarchar(250), badness float)

-- Stollen from http://data.stackexchange.com/skeptics/query/677657/network-wide-post-text-search
DECLARE @db sysname
DECLARE @Query nvarchar(max)
DECLARE c CURSOR FOR 
  SELECT Name 
  FROM sys.databases
  WHERE database_id > 5 
  AND Name NOT LiKE '%.Meta'

OPEN c
FETCH NEXT FROM c INTO @db
WHILE (@@FETCH_STATUS = 0) BEGIN
  SET @Query =
    '
use ' + QUOTENAME(@db) + ';
declare @total int = (select iif(count(*) > 0, count(*), 1)
                      from PostsWithDeleted 
                      where CreationDate >= getdate() - ##daysAgo?90##);
insert into #results
select ''' + QUOTENAME(@db) + ''' site,
       round(100.0*count(*)/@total, 1) 
from PostsWithDeleted
where (Score < 0
      or DeletionDate is not null
      or ClosedDate is not null)
      and CreationDate >= getdate() - ##daysAgo##
      and @total > 0
     '
     
  EXEC(@Query)
  FETCH NEXT FROM c INTO @db
END;
CLOSE c;
DEALLOCATE c;

select * from #results order by badness desc;

Enter Parameters

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