Daily average of number of questions between two dates

1

Please login or register to vote for this query.

(click on this box to dismiss)

Cognitive Sciences Meta

Q&A about the site for practitioners, researchers, and students in cognitive science, psychology, neuroscience, and psychiatry

; 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
  SUM(CCount) AS [Total Count],
  SUM(CCountND) AS [# Not Deleted],
  AVG(CAST(Ccount AS Decimal)) AS [Daily Average],
  AVG(CAST(CcountND AS Decimal)) AS [Average non-deleted]
FROM counts_cte
WHERE (CDate >= '##Date1?2019-01-01##') AND (CDate <= '##Date2?2020-01-01##')

Enter Parameters

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