Anton.Sandbox

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu

Q&A for Ubuntu users and developers

/* Up
*/

;WITH QuestionsSample AS
(
  SELECT q.Id, q.AcceptedAnswerId
  FROM Posts q tablesample(.1 percent)
  WHERE q.PostTypeId = 1 AND q.Id > 0
  )
SELECT q.Id as QuestionId,
  a.Id as AnswerId,
  v.VoteTypeId,
  COUNT(a.Id) as n,
  q.Id as [Post Link]
FROM Posts a
  RIGHT OUTER JOIN QuestionsSample q on a.ParentId = q.Id
  LEFT OUTER JOIN Votes v ON a.Id = v.PostId AND (v.VoteTypeId = 2 OR v.VoteTypeId = 3) AND a.PostTypeId = 2
GROUP BY q.Id, a.Id, v.VoteTypeId
ORDER BY q.Id, a.Id, v.VoteTypeId, n

Enter Parameters

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