Number of users which made their last comment in a given month

0

Please login or register to vote for this query.

(click on this box to dismiss)

Mathematics

Q&A for people studying math at any level and professionals in related fields

;  with last_cte as
(
SELECT
    UserId,
    MAX(Id) AS MaxId
FROM Comments
GROUP BY UserId
), dates_cte as
(
SELECT
  c.UserId AS odn, c.Id AS cid, c.CreationDate AS CDate
  FROM Comments c INNER JOIN last_cte ON c.Id=maxid
)

SELECT eomonth(CDate),
  COUNT(odn)
FROM dates_cte
GROUP BY eomonth(CDate) 
ORDER BY eomonth(CDate)

Enter Parameters

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