Other answer(s) with higher score than Accepted answer

2

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

-- finds Q's with 2 or more answers,
-- where accepted answer is NOT the highest score
-- gives all "other" answers scoring higher than accepted answer
--
-- ** Last "and" filters out Accepted answers with score over set threshold,
--    so remove to see all cases, or adjust threshold:
--       : higher n includes more answers;
--       : lower n excludes more answers.

-- aScoreThreshold: Set whole number (+/-) value to filter accepted answer score, higher numbers give more results.
-- Thanks PV :)

SELECT DISTINCT TOP 200 Q.Id as [Post Link],
  Q.ViewCount,
  Q.Score as qScore,
  A.Score as aScore,
  OA.Score as oaScore,
  OA.Score - A.Score as scoreDiff

FROM Posts Q, Posts A, Posts OA 

WHERE Q.AnswerCount > 1 
  AND A.ParentId = Q.Id
  AND OA.ParentId = Q.Id
  AND A.Id = Q.AcceptedAnswerId
  AND OA.Id <> Q.AcceptedAnswerId
  AND A.Score < OA.Score
  and A.Score < ##aScoreThreshold##

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results