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)

Android Enthusiasts Meta

Q&A about the site for enthusiasts and power users of the Android operating system

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 sites:
loading Hold tight while we fetch your results