Question rejections as percentage of question creations

1

Please login or register to vote for this query.

(click on this box to dismiss)

Bicycles Meta

Q&A about the site for people who build and repair bicycles, people who train cycling, or commute on bicycles

DECLARE @now DATETIME = (
  SELECT TOP 1
    DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1)
  FROM Posts
  ORDER BY Id DESC
);

WITH RejectionsRaw AS (
  SELECT
    CASE
      WHEN ClosedDate IS NULL THEN DeletionDate
      WHEN DeletionDate IS NULL THEN ClosedDate
      WHEN ClosedDate < DeletionDate THEN ClosedDate
      ELSE DeletionDate
    END AS RejectionDate
  FROM PostsWithDeleted
  WHERE
    PostTypeId = 1
    AND
    (
      ClosedDate IS NOT NULL
      OR
      DeletionDate IS NOT NULL
    )
),
Rejections AS (
  SELECT
    DATEFROMPARTS(YEAR(RejectionDate), MONTH(RejectionDate), 1) AS Month,
    COUNT(*) AS Count
  FROM RejectionsRaw
  GROUP BY DATEFROMPARTS(YEAR(RejectionDate), MONTH(RejectionDate), 1)
),
Creations AS (
  SELECT
    DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) AS Month,
    COUNT(*) AS Count
  FROM PostsWithDeleted
  WHERE PostTypeId = 1
  GROUP BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1)
)
SELECT
  Creations.Month,
  100.0 * Rejections.Count / Creations.Count AS RejPct
FROM Creations, Rejections
WHERE
  Creations.Month = Rejections.Month
  AND
  Creations.Month < @now
ORDER BY Creations.Month DESC

Enter Parameters

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