Average sum of scores for all answers of a question

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS

Q&A for administrators, end users, developers and designers for Craft CMS

SELECT AVG(q.Score * 1.0), AVG(a.Score * 1.0)
FROM Posts q
INNER JOIN
 (SELECT DISTINCT a.ParentId, SUM(a.Score) AS [Score]
 FROM Posts a
 WHERE a.PostTypeId = 2 -- answers
 GROUP BY a.ParentId) a
ON q.Id = a.ParentId
WHERE q.PostTypeId = 1 -- questions
and q.ClosedDate is null -- not closed
and q.Score <= 0 and q.ViewCount >= 2000

Enter Parameters

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