I am looking for a SQL query that computes the average time to comment (measured for every month).
I was able to write a query that measures the average time between the original post datetime and the comment datetime but still this is not correct as the time should be measured between the current comment and the previous one, as they are related most of the time.
select
dateadd(month, datediff(month, 0, Comments.creationdate),0) [Date],
AVG(CAST(DATEDIFF(hour, Posts.CreationDate, Comments.creationdate ) AS BigInt)) [DelayHours]
from comments
INNER JOIN posts ON Comments.PostId = Posts.Id
GROUP BY
dateadd(month, datediff(month, 0, Comments.creationdate),0)
ORDER BY Date