Yet another Upvote/Month stat

1

Please login or register to vote for this query.

(click on this box to dismiss)

Moderators

Q&A for community managers, administrators, and moderators

WITH Raw AS (
  SELECT
    DATEFROMPARTS(
      DATEPART(yyyy, CreationDate),
      DATEPART(mm, CreationDate),
      1) AS Month,
    'Votes' AS Type,
    COUNT(*) AS Count
  FROM Votes
  WHERE VoteTypeId = 2
  GROUP BY DATEFROMPARTS(
    DATEPART(yyyy, CreationDate),
    DATEPART(mm, CreationDate),
    1)
  
  UNION
  
  SELECT
    DATEFROMPARTS(
      DATEPART(yyyy, CreationDate),
      DATEPART(mm, CreationDate),
      1) AS Month,
    'Feedback' AS Type,
    COUNT(*) AS Count
  FROM PostFeedback
  WHERE VoteTypeId = 2
  GROUP BY DATEFROMPARTS(
    DATEPART(yyyy, CreationDate),
    DATEPART(mm, CreationDate),
    1)
)
SELECT *
FROM Raw

UNION

SELECT
  Month,
  'Both' AS Type,
  SUM(Count) AS Count
FROM Raw
GROUP BY Month
ORDER BY Month;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results