Question count by the number of answers per question

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

Select
    q.Cnt as AnswerCount,
    count(*) as QuestionCount --,
    --count(*) * 100.0 / (select count(*) from Posts a where a.PostTypeId = 2) as Percent
from (
  Select q.Id as Id, (
    Select count(*) from Posts a
    where a.ParentId = q.Id and a.PostTypeId = 2
    ) as Cnt
  from Posts q
  where q.PostTypeId = 1
  ) as q
group by q.Cnt
order by q.Cnt

Enter Parameters

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