Q&A about the site for members of the workforce navigating the professional setting
WITH FirstAnswers AS ( SELECT p.Id AS QuestionId, MIN(a.CreationDate) AS FirstAnswerDate FROM Posts p LEFT JOIN Posts a ON p.Id = a.ParentId AND a.PostTypeId = 2 WHERE p.PostTypeId = 1 AND p.CreationDate > DATEADD(YEAR, -1, GETDATE()) -- Analyzing questions from the last year GROUP BY p.Id ) SELECT LEN(q.Body) AS QuestionLength, AVG(DATEDIFF(MINUTE, q.CreationDate, fa.FirstAnswerDate)) AS AvgTimeToFirstAnswer FROM Posts q LEFT JOIN FirstAnswers fa ON q.Id = fa.QuestionId WHERE q.PostTypeId = 1 AND q.CreationDate > DATEADD(YEAR, -1, GETDATE()) GROUP BY LEN(q.Body) ORDER BY QuestionLength;