with AnswersUserMonth as ( select dateadd(month, datediff...

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

with AnswersUserMonth as
(
  select dateadd(month, datediff(month, 0, CreationDate), 0) m, OwnerUserId, count(*) Answers
  from Posts
  where PostTypeId=2
  and OwnerUserId<>-1
  and CreationDate >= '2008-8-1'
  group by dateadd(month, datediff(month, 0, CreationDate), 0), OwnerUserId
),
AnswersMonth as
(
  select m, sum(Answers) TotalAnswers
  from AnswersUserMonth
  group by m
)

select aum.m, (case when Answers=1 then 'single answer' when Answers <= 10 then '<= 10' when Answers <= 100 then '<= 100' else '> 100' end), sum(Answers)
from AnswersUserMonth aum
group by aum.m, (case when Answers=1 then 'single answer' when Answers <= 10 then '<= 10' when Answers <= 100 then '<= 100' else '> 100' end)
order by aum.m

Enter Parameters

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