Questions answed and closed by week

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @FirstQuestion datetime = (SELECT CreationDate FROM dbo.Posts WHERE Id = 1) + 1;
DECLARE @LastQuestion datetime = (SELECT MAX(CreationDate) FROM dbo.Posts WHERE PostTypeId = 1);


select CAST(DATEADD(week, DATEDIFF(week, @LastQuestion, CreationDate), @LastQuestion) AS Date) Week,
       count(*) Questions, 
       count(ClosedDate) Closed, 
--       count(DeletionDate) Deleted,
       sum(case when AnswerCount > 0 then 1 else 0 end) Answered
from Posts
where PostTypeId = 1
group by DATEDIFF(week, @LastQuestion, CreationDate)
order by DATEDIFF(week, @LastQuestion, CreationDate)

Enter Parameters

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