Q&A for professional and enthusiast programmers
select year(creationdate) , sum(case when posttypeid=1 and deletiondate is null then 1 else 0 end) as Q , sum(case when posttypeid=2 and deletiondate is null then 1 else 0 end) as A , sum(case when posttypeid=1 and deletiondate is not null then 1 else 0 end) as [ deleted Q] , sum(case when posttypeid=2 and deletiondate is not null then 1 else 0 end) as [deleted A] , sum(case when posttypeid=4 and deletiondate is null then 1 else 0 end) as [tag excerpt] , sum(case when posttypeid=5 and deletiondate is null then 1 else 0 end) as [tag wiki] from postswithdeleted group by year(creationdate) order by year(creationdate)