Evolution of daily average of number of questions (per month)

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

; with counts_cte AS (
SELECT
  CAST(CreationDate AS DATE) AS CDate,
  COUNT(q.Id) AS CCount,
  SUM(Case When q.DeletionDate IS NULL Then 1 Else 0 End) AS CCountND
FROM PostsWithDeleted q
WHERE (q.PostTypeId=1)
---only questions
GROUP BY CAST(CreationDate AS DATE)
)

SELECT
  eomonth(CDate) AS Month,
  AVG(CAST(Ccount AS Decimal)) AS [Daily Average],
  AVG(CAST(CcountND AS Decimal)) AS [Average non-deleted]
FROM counts_cte  
GROUP BY eomonth(CDate)
ORDER BY eomonth(CDate)

Enter Parameters

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