Post creations, closures and deletions grouped by day of week

1

Please login or register to vote for this query.

(click on this box to dismiss)

Chess

Q&A for serious players and enthusiasts of chess

WITH Raw AS (
  SELECT
    DATEPART(dw, ClosedDate) AS ClosureDay,
    DATEPART(dw, DeletionDate) AS DeletionDay,
    DATEPART(dw, CreationDate) AS CreationDay
  FROM PostsWithDeleted
  WHERE PostTypeId = 1
)
SELECT ClosureDay AS Day, 'Closure' AS EventType, COUNT(*) AS Count
FROM Raw
WHERE ClosureDay IS NOT NULL
GROUP BY ClosureDay

UNION ALL

SELECT DeletionDay AS Day, 'Deletion' AS EventType, COUNT(*) AS Count
FROM Raw
WHERE DeletionDay IS NOT NULL
GROUP BY DeletionDay

UNION ALL

SELECT CreationDay AS Day, 'Creation' AS EventType, COUNT(*) AS Count
FROM Raw
WHERE CreationDay IS NOT NULL
GROUP BY CreationDay

ORDER BY Day, EventType

Enter Parameters

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