Highest scoring questions and answer by tag

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

SELECT TagName,
  QuestionID AS [Post Link], q_.OwnerUserId AS [User Link], q_.Score AS [Q score],
  AnswerID AS [Post Link], a_.OwnerUserId AS [User Link], a_.Score AS [A score]
FROM
(SELECT TagName,
  (SELECT TOP 1 q.Id
     FROM Posts AS q INNER JOIN PostTags AS qt ON q.Id = qt.PostId
     WHERE qt.TagId = t.Id ORDER BY q.Score DESC) AS QuestionID,
  (SELECT TOP 1 a.Id
     FROM Posts AS a INNER JOIN PostTags AS at ON a.ParentId = at.PostId
     WHERE at.TagId = t.Id ORDER BY a.Score DESC) AS AnswerID
  FROM Tags AS t
  WHERE t.TagName = ##TagName:string##) AS temp
  INNER JOIN Posts AS q_ ON temp.QuestionId = q_.Id
  LEFT OUTER JOIN Posts AS a_ ON temp.AnswerId = a_.Id

Enter Parameters

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