SELECT qId, count(*) as cnt FROM( SELECT q.Id as qId, c.I...

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 qId, count(*) as cnt FROM(
SELECT q.Id as qId, c.Id
FROM Posts q
INNER JOIN Posts aa on q.AcceptedAnswerId = aa.Id
INNER JOIN Votes vaa on vaa.PostId = aa.Id
INNER JOIN Posts a on a.ParentId=q.Id
INNER JOIN Comments c on a.Id=c.PostId
WHERE vaa.VoteTypeId = 1
AND a.CreationDate < vaa.CreationDate
UNION ALL
SELECT q.Id as qId, c.Id
FROM Posts q
INNER JOIN Posts aa on q.AcceptedAnswerId = aa.Id
INNER JOIN Votes vaa on vaa.PostId = aa.Id
INNER JOIN Posts a on a.ParentId=q.Id
INNER JOIN Comments c on q.Id=c.PostId
WHERE vaa.VoteTypeId = 1
AND a.CreationDate < vaa.CreationDate) as blah
GROUP BY qId

Enter Parameters

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