Most self-answered questions with accepted answer of another user

1

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

CREATE TABLE #SelfAnswered (
  Id INT PRIMARY KEY,
  OwnerUserId INT,
  AcceptedAnswerId INT
)

INSERT INTO #SelfAnswered
SELECT
  Q.Id,
  MIN(Q.OwnerUserId) AS OwnerUserId,
  MIN(Q.AcceptedAnswerId) AS AcceptedAnswerId
FROM Posts Q, Posts A
WHERE
  A.ParentId = Q.Id
  AND
  A.OwnerUserid = Q.OwnerUserId
  AND
  Q.OwnerUserId > 0
GROUP BY Q.Id

SELECT TOP 100 #SelfAnswered.OwnerUserId AS [User Link], COUNT(*) AS Count
FROM #SelfAnswered, Posts A
WHERE
  #SelfAnswered.OwnerUserId <> A.OwnerUserId
  AND
  #SelfAnswered.AcceptedAnswerId = A.Id
GROUP BY #SelfAnswered.OwnerUserId
ORDER BY Count DESC, #SelfAnswered.OwnerUserId

Enter Parameters

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