SELECT 100*(CAST(AggregatedResults.CountOfQuestionsWhereA...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Arqade

Q&A for passionate videogamers on all platforms

SELECT 100*(CAST(AggregatedResults.CountOfQuestionsWhereAcceptedAnswerIsNotTheHighestVotes AS FLOAT)/CAST(AggregatedResults.CountOfQuestionsWithMoreThanOneAnswer AS FLOAT)) AS [Percentage],
AggregatedResults.CountOfQuestionsWhereAcceptedAnswerIsNotTheHighestVotes,
AggregatedResults.CountOfQuestionsWithMoreThanOneAnswer
FROM
(
SELECT 
    (SELECT Count(NUM1.Id) AS CountOfQuestionsWithMoreThanOneAnswer
      FROM (SELECT P.Id
            FROM POSTS P
            WHERE P.PostTypeId = 1
            AND P.AcceptedAnswerId IS NOT NULL
            AND P.AnswerCount >= 2) AS NUM1) CountOfQuestionsWithMoreThanOneAnswer,
            
    (SELECT COUNT(NUM2.Id) AS CountOfQuestionsWhereAcceptedAnswerIsNotTheHighestVotes
      FROM 
      (SELECT p1.Id
      FROM POSTS p1  
      INNER JOIN POSTS acc on acc.Id = p1.AcceptedAnswerId
      INNER JOIN POSTS ans on ans.ParentId = p1.Id and ans.PostTypeId = 2 and ans.Id != acc.Id
      WHERE p1.PostTypeId = 1
      GROUP BY p1.Id, p1.Title, acc.Score
      HAVING MAX(ans.Score) > acc.Score) NUM2) CountOfQuestionsWhereAcceptedAnswerIsNotTheHighestVotes
) AggregatedResults

Enter Parameters

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