highest voted answer is the accepted answer, and at least 2 answers exist

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.Id as [Post Link], 
max(aa.score) as 'aa score'
from 
Posts as q 
left join Posts as aa on q.Id = aa.ParentId --- aa: accepted answer
where 
q.PostTypeId = 1 and
q.AcceptedAnswerId is not null and
q.AnswerCount > 1 and
aa.Id = q.AcceptedAnswerId and
aa.Score = (Select max(score) from Posts csq where csq.ParentId = q.id)
group by q.id
order by max(aa.score) DESC;

Enter Parameters

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