Questions and Answers per Month

0

Please login or register to vote for this query.

(click on this box to dismiss)

Joomla

Q&A for Joomla! administrators, users, developers and designers

select [Month], 
       sum(case when                      Score >= 1 then 1 else 0 end) All_Questions1,
       sum(case when AnswerCount > 0 and  Score >= 1 then 1 else 0 end) Questions_with_Answers1,
       sum(case when                      Score >= 2 then 1 else 0 end) All_Questions2,
       sum(case when AnswerCount > 0 and  Score >= 2 then 1 else 0 end) Questions_with_Answers2,
       sum(case when                      Score >= 3 then 1 else 0 end) All_Questions3,
       sum(case when AnswerCount > 0 and  Score >= 3 then 1 else 0 end) Questions_with_Answers3,
       sum(case when Score >= 4 then 1 else 0 end) All_Questions4,
       sum(case when AnswerCount > 0 and Score >=4 then 1 else 0 end) Questions_with_Answers4,
       sum(case when Score > -10 then 1 else 0 end) All_Questions0,
       sum(case when AnswerCount > 0 and Score >-101 then 1 else 0 end) Questions_with_Answers0
from
(
  select CAST(
      cast(DATEPART(YYYY, CreationDate) as varchar) + '-' + cast(DATEPART(MM, CreationDate) as varchar) + '-01'
    as datetime) [Month], 
    AnswerCount, Score
     
  from Posts p
  where PostTypeId = 1 and ClosedDate is NULL
) as X
group by [Month]
order by [Month] asc

Enter Parameters

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