Count of the users with a positively scored post by month

1

Please login or register to vote for this query.

(click on this box to dismiss)

Physical Fitness Meta

Q&A about the site for physical fitness professionals, athletes, trainers, and those providing health-related needs

DECLARE @TsNow DATETIME;

SELECT @TsNow = DATEFROMPARTS(
  DATEPART(yyyy, MAX(CreationDate)),
  DATEPART(mm, MAX(CreationDate)),
  1)
FROM Posts;

WITH Raw AS (
  SELECT DISTINCT
    DATEFROMPARTS(
      DATEPART(yyyy, CreationDate),
      DATEPART(mm, CreationDate),
      1) AS Month,
    OwnerUserId AS UserId
  FROM Posts
  WHERE
    CreationDate < @TsNow
    AND
    Score > 0
)
SELECT
  Month,
  COUNT(*) AS Count
FROM Raw
GROUP BY Month
ORDER BY Month

Enter Parameters

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