Q&A about the site for administrators, end users, developers and designers for Craft CMS
;with diffs as ( select YEAR(q.CreationDate) * 100 + MONTH(q.CreationDate) as TheMonth, cast(a.CreationDate - q.CreationDate as float) as d, row_number() over (PARTITION BY q.Id ORDER BY a.CreationDate) AS RowNo from Posts q join Posts a on a.ParentId = q.Id where a.Score > 0 -- and q.CreationDate >= '20180101' ) select TheMonth, avg(d) as AvgTimeToGetAnAnswer from diffs where RowNo = 1 group by TheMonth order by TheMonth ;with diffs as ( select YEAR(a.CreationDate) * 100 + MONTH(a.CreationDate) as TheMonth, cast(a.CreationDate - q.CreationDate as float) as d from Posts q join Posts a on a.Id = q.AcceptedAnswerId where a.Score > 0 ) select TheMonth, avg(d) as AvgTimeToGetAnAnswer from diffs group by TheMonth order by TheMonth