Probability of a question to left open, not deleted and non-negative score by month

1

Please login or register to vote for this query.

(click on this box to dismiss)

Vegetarianism

Q&A for those committed to a vegan or vegetarian lifestyle and anyone interested in learning more

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

WITH Raw AS (
  SELECT
    DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) AS Month,
    COUNT(*) AS CreatedCount,
    COUNT(CASE
        WHEN ClosedDate IS NOT NULL OR DeletionDate IS NOT NULL OR Score < 0
        THEN 1
      END) AS RejectedCount
  FROM PostsWithDeleted
  WHERE PostTypeId = 1
  GROUP BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1)
)
SELECT
  Month,
  CASE
    WHEN ##ShowPercentage:int?0## <> 0
    THEN 100.0 * RejectedCount / CreatedCount
  END AS RejectionPct,
  CASE WHEN ##ShowPercentage## = 0 THEN RejectedCount END AS RejectedCount,
  CASE WHEN ##ShowPercentage## = 0 THEN CreatedCount END AS CreatedCount
FROM Raw
WHERE Month < @now
ORDER BY Month DESC

Enter Parameters

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