Answered rate by score band and month asked

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

declare @epoch datetime = 'March 1, 2014'

select dateadd(month, datediff(month, @epoch, q.CreationDate), @epoch) Month,
       --iif(Score > 0, 'welcome', 'unwelcome') type,
       case 
        when Score < 0 then '< 0'
        when Score = 0 then '0'
        when Score = 1 then '1'
        when Score = 2 then '2'
        when Score = 3 then '3'
        when Score = 4 then '4'
        else '5+'
        end band,
       1.0*count(iif(AnswerCount > 0, 1, null))/count(*) "answer rate"
from Posts q 
where PostTypeId = 1
      and Score between -10 and 10
group by datediff(month, @epoch, q.CreationDate),
       --iif(Score > 0, 'welcome', 'unwelcome'),
      case 
        when Score < 0 then '< 0'
        when Score = 0 then '0'
        when Score = 1 then '1'
        when Score = 2 then '2'
        when Score = 3 then '3'
        when Score = 4 then '4'
        else '5+'
        end
order by band desc, Month;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results