SELECT cast(AggregatedResults.CountOfQuestionsWhereAccept...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Japanese Language Meta

Q&A about the site for students, teachers, and linguists wanting to discuss the finer points of the Japanese language

SELECT 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 main site
loading Hold tight while we fetch your results