Questions and Answers per Month

0

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

select [Month], 
       sum(case when PostTypeId = 1 then 1 else 0 end) Questions,
       sum(case when PostTypeId = 2 then 1 else 0 end) Answers,
       sum(case when PostTypeId = 3 then 1 else 0 end) Wiki,
       sum(case when PostTypeId = 4 then 1 else 0 end) TagWikiExcerpt,
       sum(case when PostTypeId = 5 then 1 else 0 end) TagWiki,
       sum(case when PostTypeId = 6 then 1 else 0 end) ModeratorNomination,
       sum(case when PostTypeId = 7 then 1 else 0 end) WikiPlaceholder,
       sum(case when PostTypeId = 8 then 1 else 0 end) PrivilegeWiki
       
from
(
  select CAST(
      cast(DATEPART(YYYY, CreationDate) as varchar) + '-' + cast(DATEPART(MM, CreationDate) as varchar) + '-01'
    as datetime) [Month], 
    PostTypeId
     
  from Posts p
  where CreationDate < dateadd(month,datediff(m,0,GETDATE()),0)
) as X
group by [Month]
order by [Month] asc

Enter Parameters

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