Answers per question hourwise

1

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 [Month], 
       sum(case when PostTypeId = 2 then 1 else 0 end)/sum(case when PostTypeId = 1 then 1 else 0 end) APerQ
from
(
  select CAST(
  cast(DATEPART(YYYY, CreationDate) as varchar) + '-' + cast(DATEPART(MM, CreationDate) as varchar) +'-'+cast(DATEPART(DD,CreationDate) as varchar)+ ' '+ cast(DATEPART(HH, CreationDate) as varchar)+':00:00'
    as datetime) [Month], 
    PostTypeId
     
  from Posts p where cast(DATEPART(YYYY, CreationDate) as varchar)='2013' and cast(DATEPART(MM, CreationDate) as varchar)=7
) as X
group by [Month]
order by [Month] asc

Enter Parameters

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