Answer counts for questions where accepted answer is not top-voted


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 TopAnswerScore as (
select q.Id as question, max(a.Score) as topscore 
from posts q 
inner join posts a on a.ParentId=q.Id 
group by q.Id

select isnull(p.AnswerCount, 0), count(*) N
from Posts p
inner join TopAnswerScore on question = p.Id
where exists (
  select a.Id from Posts a 
  where a.Id = p.AcceptedAnswerId
  and a.Score < topscore

group by isnull(p.AnswerCount, 0)
order by isnull(p.AnswerCount, 0)

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results