Q&A for developers and researchers interested in open data
-- The best time to ask questions -- Look for the minimum value on y-scale: -- It says when the time between question and answer is minimal. -- For example DECLARE @Frequency int = ##Frequency:int?3## DECLARE @Cond nvarchar(300) = '' ;WITH tmp AS ( SELECT timeDiff = DATEDIFF(minute, q.CreationDate, a.CreationDate), Period = CASE @Frequency WHEN 1 THEN DATEPART("hour", q.CreationDate) WHEN 2 THEN DATEPART("weekday", q.CreationDate) WHEN 3 THEN ROUND((CAST(DATEPART("weekday", q.CreationDate) AS numeric) + CAST(DATEPART("hour", q.CreationDate) AS numeric) / 24), 2) END FROM Posts q LEFT OUTER JOIN Posts a ON q.AcceptedAnswerId = a.Id WHERE q.AcceptedAnswerId > 0 ) SELECT Period, AVG(timeDiff) FROM tmp WHERE timeDiff < 1440 GROUP BY Period ORDER BY Period