SELECT cdate, Questions as [Questions added per day], Ans...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Interpersonal Skills

Q&A for people looking to improve their interpersonal communication skills

SELECT 
  cdate,
  Questions as [Questions added per day], Answers as [Answers added per day],
  avg(Questions) over(ORDER BY cdate ROWS BETWEEN 30 PRECEDING AND CURRENT ROW) as [Questions added per day, 30 day rolling avg],
  avg(Answers) over(ORDER BY cdate ROWS BETWEEN 30 PRECEDING AND CURRENT ROW) as [Answers added per day, 30 day rolling avg]
  FROM (SELECT
    CAST(CreationDate AS DATE) AS cdate,
    0.0+COUNT(ParentId) AS Answers, 
    0.0+SUM(CASE WHEN ParentId IS NULL THEN 1 ELSE 0 END) AS Questions
  FROM Posts
  WHERE CreationDate > '2017-08-01'
  GROUP BY CAST(CreationDate AS DATE)
  ) foo
ORDER BY cdate

Enter Parameters

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