select year(creationdate) , sum(case when posttypeid=1 an...

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

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)

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results