Number of custom off-topic close reasons for each site

0

Please login or register to vote for this query.

(click on this box to dismiss)

Science Fiction and Fantasy

Q&A for science fiction and fantasy enthusiasts

DECLARE @command NVARCHAR(1024) = 'USE [?];
IF ''?'' NOT LIKE ''%meta%''
AND ''?'' <> ''StackApps''
AND EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ''CloseAsOffTopicReasonTypes'')
INSERT INTO #Counts
SELECT replace(''?'', ''StackExchange.'', ''''), count(*)
FROM dbo.CloseAsOffTopicReasonTypes
WHERE ApprovalDate is not null and DeactivationDate is null;'

CREATE TABLE #Counts (Site NVARCHAR(255), Count INT);
EXEC sp_msforeachdb @command

SELECT Site, Count
FROM #Counts
ORDER BY Count desc, Site

select Count, count(Count) as [Number of Sites]
from #Counts
group by Count

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results