Q&A about the site for anime and manga fans
SELECT DATEDIFF(MINUTE, q.CreationDate, a.CreationDate), COUNT(*) AS 'Number of questions answered within x minutes' FROM Posts AS q CROSS APPLY ( SELECT MIN(CreationDate) AS CreationDate FROM Posts WHERE ParentId = q.Id AND OwnerUserId = ##UserId:int## -- merged questions can have older answers AND CreationDate >= q.CreationDate ) a WHERE DATEDIFF(MINUTE, q.CreationDate, a.CreationDate) < 300 GROUP BY DATEDIFF(MINUTE, q.CreationDate, a.CreationDate) ORDER BY DATEDIFF(MINUTE, q.CreationDate, a.CreationDate)