instruction: % Answers by author account age.
response: WITH AnswersByMonth AS (SELECT DATEADD(month, DATEDIFF(month, 0, CreationDate), 0) AS mo, COUNT(*) AS Answers FROM Posts AS a WHERE PostTypeId = 2 GROUP BY DATEADD(month, DATEDIFF(month, 0, CreationDate), 0)) SELECT mo, CAST(DATEDIFF(month, u.CreationDate, CreationDate) / 12 AS VARCHAR(8)) AS AccountAgeYears, COUNT(*) * 100.0 / Answers AS PctAnswers FROM Posts AS a JOIN AnswersByMonth AS abm ON abm.mo = DATEADD(month, DATEDIFF(month, 0, CreationDate), 0) JOIN Users AS u ON u.Id = a.OwnerUserId AND u.CreationDate < a.CreationDate WHERE PostTypeId = 2 GROUP BY mo, DATEDIFF(month, u.CreationDate, CreationDate) / 12, Answers ORDER BY mo