answers per question over time

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

-- answers per question over time

select *, (answers + 0.0) / (questions + 0.0) [answer per question], votes / (answers + questions + 0.0) [votes per post]
from (
select start, 
       sum(case when PostTypeId = 1 then 1 else 0 end) questions,  
       sum(case when PostTypeId = 2 then 1 else 0 end) answers, 
       (
         select count(*) from Votes v 
join Posts p2 on p2.Id = v.PostId
where VoteTypeId in (1,2) 
and p2.CreationDate between start and finish  
and v.CreationDate between start and finish
and p2.CommunityOwnedDate is null
       ) as votes

from Posts p
join master.dbo.fnGetDateRanges('m','1-1-2009','1-1-2011') on 
  p.CreationDate between start and finish
where CommunityOwnedDate is null
 and Score > 0
group by start,finish
) as X
order by start

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached