Yet another site liveness stat - this time by monthly votes + feedbacks

1

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers

Q&A for Drupal developers and administrators

DECLARE @now DATETIME = (SELECT MAX(CreationDate) FROM Votes);

SET @now = DATEFROMPARTS(YEAR(@now), MONTH(@now), 1);

WITH Raw AS (
  SELECT
    DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) AS Month,
    'Votes' AS Type,
    COUNT(*) AS Count
  FROM Votes
  GROUP BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1)

  UNION ALL

  SELECT
    DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) AS Month,
    'Feedbacks' AS Type,
    COUNT(*) AS Count
  FROM PostFeedBack
  GROUP BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1)
)
SELECT * FROM Raw
UNION
SELECT
  Month,
  'Both' AS Type,
  SUM(Count) AS Count
FROM Raw
WHERE Month < @now
GROUP BY Month
ORDER BY Month

Enter Parameters

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