Average time until the first answer - restricted to users from the list

1

Please login or register to vote for this query.

(click on this box to dismiss)

Emacs

Q&A for those using, extending or developing Emacs

with answered_cte AS
(
SELECT
  q.Id AS qid,
  q.CreationDate AS created,
  MIN(a.CreationDate) AS answered
FROM Posts q INNER JOIN Posts a ON a.ParentId=q.Id
WHERE (q.PostTypeId=1) and (q.AnswerCount>0)
---only question which have at least one answer
  and (a.OwnerUserId IN(##list?2,3,66,121,1409,2000,2926##))
---restricted to these users  
GROUP BY q.Id, q.CreationDate
), times_cte AS
(
SELECT
  top (##num?1000##)
  qid AS qid,
  DATEDIFF(month, created, answered) AS Months,
  DATEDIFF(day, created, answered) AS Days,
  DATEDIFF(hour, created, answered) AS Hours,
  DATEDIFF(minute, created, answered) AS Minutes
FROM answered_cte
)

SELECT
 AVG(CAST(t.Months AS decimal)) AS [Average # of Months],  
 AVG(CAST(t.Days AS decimal)) AS [Average # of Days],  
 AVG(CAST(t.Hours AS decimal)) AS [Average # of Hours],
 AVG(CAST(t.Minutes AS decimal)) AS [Average # of Minutes]
FROM times_cte t

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results