Questions and Answers per Month

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

select [Month], 
sum(case when PostTypeId = 1 and (DeletionDate IS NULL) then 1 else 0 end) NonDeletedQuestions,
       sum(case when PostTypeId = 2 and (DeletionDate IS NULL) then 1 else 0 end) NonDeletedAnswers,
sum(case when PostTypeId = 1 and (DeletionDate IS NULL) then 1 else 0 end) DeletedQuestions,
       sum(case when PostTypeId = 2 and (DeletionDate IS NULL) then 1 else 0 end) DeletedAnswers
from
(
  select CAST(
      cast(DATEPART(YYYY, CreationDate) as varchar) + '-' + cast(DATEPART(MM, CreationDate) as varchar) + '-01'
    as datetime) [Month], DeletionDate, CreationDate,
    PostTypeId
     
  from PostsWithDeleted p
) as X
group by [Month]
order by [Month] asc

Enter Parameters

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