Number of posts per week - between two dates (including the deleted posts)

1

Please login or register to vote for this query.

(click on this box to dismiss)

MathOverflow

Q&A for professional mathematicians

SELECT 
---DATEPART("week", CreationDate) [week],
  DATEADD(dd, -(DATEPART(dw, CreationDate)-1), CreationDate) [WeekStart],
  COUNT(p.Id) AS [Total Posts],
  SUM(case when p.PostTypeId = 1 then 1 else 0 end) AS [Total Questions],
  SUM(case when p.PostTypeId = 2 then 1 else 0 end) AS [Total Answers]
FROM PostsWithDeleted p
WHERE (p.CreationDate >= '##Date1?2022-01-01##') AND (p.CreationDate <= '##Date2?2023-01-01##')
GROUP BY DATEADD(dd, -(DATEPART(dw, CreationDate)-1), CreationDate)
ORDER BY DATEADD(dd, -(DATEPART(dw, CreationDate)-1), CreationDate)

Enter Parameters

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