Questions and Answers per Week

0

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

select [Week], 
       sum(case when PostTypeId = 1 then 1 else 0 end) Questions,
       sum(case when PostTypeId = 1 then 0 else 1 end) Answers
from
(
  select
      cast(DATEPART(YYYY, CreationDate) as varchar) 
      + '-W' + cast(DATEPART(ISO_WEEK, CreationDate) as varchar)
     [Week], 
    PostTypeId
     
  from Posts p
  where CreationDate < dateadd(month,datediff(m,0,GETDATE()),0)
) as X
group by [Week]
order by [Week] asc

Enter Parameters

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