Q&A for those who study, teach, research and apply economics and econometrics
select [Month], sum(case when PostTypeId = 1 then 1 else 0 end) Questions, sum(case when PostTypeId = 2 then 1 else 0 end) Answers from ( select CAST( cast(DATEPART(YYYY, CreationDate) as varchar) + '-' + cast(DATEPART(MM, CreationDate) as varchar) + '-01' as datetime) [Month], PostTypeId from Posts p ) as X group by [Month] order by [Month] asc