Populist candidates; your answer outscores the accepted answer

0

Please login or register to vote for this query.

(click on this box to dismiss)

Questions where your answer has more than twice the score of the accepted answer which in turn must have a score of 11 or higher

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT
    Question.Id AS [Post Link],
    AcceptedAnswer.Score AS [Accepted Score],
    YourAnswer.Score AS [Your Score],
    CONVERT(DECIMAL(4,2), CAST(YourAnswer.Score AS float) / AcceptedAnswer.score) AS ScoreRatio,
    CASE
        WHEN AcceptedAnswer.Score > 10
        THEN 0
        ELSE 11 - AcceptedAnswer.Score
    END AS [Accepted votes needed],
    CASE
        WHEN YourAnswer.Score > AcceptedAnswer.Score * 2 AND YourAnswer.Score > 22
        THEN 0
        ELSE (CASE WHEN AcceptedAnswer.Score > 10 THEN AcceptedAnswer.Score ELSE 11 END) * 2 - YourAnswer.Score + 1
    END as [Your votes needed],
    CASE WHEN AcceptedAnswer.Score > 10 THEN 0 ELSE 11 - AcceptedAnswer.Score END
    + CASE
        WHEN YourAnswer.Score > AcceptedAnswer.Score * 2 AND YourAnswer.Score > 22
        THEN 0
        ELSE ((CASE WHEN AcceptedAnswer.Score > 10 THEN AcceptedAnswer.Score ELSE 11 END) * 2 - YourAnswer.Score + 1)
      END as [Total votes needed]
FROM Posts Question
JOIN Posts AcceptedAnswer
  ON Question.AcceptedAnswerId = AcceptedAnswer.Id
JOIN Posts YourAnswer
  ON YourAnswer.ParentId = Question.Id
WHERE YourAnswer.OwnerUserId = ##UserId##
  -- your answer scores higher than the accepted answer
  AND YourAnswer.Score > AcceptedAnswer.Score 
  -- and the accepted answer is *approaching* the minimum requirement of 11 or higher
  AND AcceptedAnswer.Score >= ##MinAcceptedScore:int?9##
ORDER BY CAST(YourAnswer.Score as float) / AcceptedAnswer.score DESC

Enter Parameters

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