Sports SE monthly traffic

0

Please login or register to vote for this query.

(click on this box to dismiss)

Music Fans Meta

Q&A about the site for music historians, critics, and fans

-- final group
select eom
     , sum(q) as Questions
     , sum(a) as Answers
     , sum(dq) as [Deleted Questions]
     , sum(da) as [Deleted Answers]
     , sum(q+a+dq+da) as [Aggregate Traffic]

from 
(
-- all questions and answers 
select eomonth(creationdate) as eom
     , sum(case 
           when posttypeid = 1 then 1 
           else 0
          end
       ) as Q
     , sum(case 
           when posttypeid = 2 then 1 
           else 0 
           end
       ) as A
     , 0 as dq
     , 0 as da
from postswithdeleted p
group by eomonth(creationdate)
union 
-- when posts were deleted
select eomonth(deletiondate)
     , 0 
     , 0
     , sum(case 
           when posttypeid = 1 then 1 
           else 0
           end) as DQ
     , sum(case 
           when posttypeid = 2 then 1 
           else 0 
           end ) as DA
from postswithdeleted p
where p.deletiondate is not null
group by eomonth(deletiondate)
) as alldata
group by eom
order by eom

Enter Parameters

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