My Answer Count Over Time By Month (forked)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS

Q&A for administrators, end users, developers and designers for Craft CMS

With MyPostsWithDates AS (
  SELECT p.Id, p.CreationDate, FORMAT(p.CreationDate, 'yyyy-MM') As DateFormat,
         p.Score, p.OwnerUserId, p.PostTypeId, p.Tags
  FROM Posts p
  WHERE p.OwnerUserId = 38408
)

SELECT CAST(d.DateFormat+'-01' AS DATETIME)
      ,COUNT(CASE WHEN d.PostTypeId=2 THEN 1 END) AS [Answer Count]
      ,SUM(CASE WHEN d.PostTypeId=1 THEN d.Score END) AS [Question Score]
      ,SUM(CASE WHEN d.PostTypeId=2 THEN d.Score END) AS [Answer Score]    
FROM MyPostsWithDates d
GROUP BY d.DateFormat
ORDER BY d.DateFormat

Enter Parameters

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