Number of open, closed and deleted questions by month

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT A.Month, OpenQ, ROUND(CAST(OpenQ as FLOAT) / B.AllQuestions * 100, 3) as Percentage

FROM

(SELECT
  DATEFROMPARTS(
    DATEPART(yyyy, CreationDate),
    DATEPART(mm, CreationDate),
    1) AS 'Month',
  COUNT(CASE
    WHEN DeletionDate IS NULL AND ClosedDate IS NULL THEN 1
    ELSE NULL
  END) AS 'OpenQ'
  FROM PostsWithDeleted
  WHERE PostTypeId=1
  GROUP BY DATEFROMPARTS(
      DATEPART(yyyy, CreationDate),
      DATEPART(mm, CreationDate),
      1)
      ) as A

JOIN

(SELECT 
  COUNT(*) AS AllQuestions
  FROM PostsWithDeleted) as B
  
ON 1=1

ORDER BY Month

Enter Parameters

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