Questions with multiple accepted answers

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

WITH
QuestionsWithAcceptedAnswers AS (
  SELECT
    Q.Id AS QuestionId,
    A.Id AS AnswerId,
    A.CreationDate AS AnswerDate,
    A.DeletionDate,
    V.CreationDate AS AcceptanceDate
  FROM Posts Q
  JOIN PostsWithDeleted A ON (A.parentId = Q.Id AND Q.PostTypeId = 1 AND A.PostTypeId = 2)
  JOIN Votes V ON (A.Id = V.PostId AND  V.VoteTypeId = 1)
),
QuestionsWithMultipleAcceptedAnswers AS (
  SELECT
    QuestionId,
    COUNT(*) AS AnswerCount
  FROM QuestionsWithAcceptedAnswers
  GROUP BY QuestionId
  HAVING COUNT(*) > 1
)
SELECT
  QM.AnswerCount,
  QA.QuestionId AS [Post Link],
  QA.AnswerId AS [Post Link],
  QA.AnswerDate,
  QA.DeletionDate,
  QA.AcceptanceDate
FROM QuestionsWithMultipleAcceptedAnswers QM
JOIN QuestionsWithAcceptedAnswers QA ON (QM.QuestionId = QA.QuestionId)
ORDER BY
  QM.QuestionId,
  QA.AcceptanceDate

Enter Parameters

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