count of questions 1 hour,1-5 hours,5-24 hours,1-7 days , more than 7 days

0

Please login or register to vote for this query.

(click on this box to dismiss)

SharePoint

Q&A for SharePoint enthusiasts

SELECT q.Id AS QuestionId,
       q.Title,
       q.CreationDate AS QuestionCreationDate,
       MIN(a.CreationDate) AS FirstAnswerDate,
       DATEDIFF(DAY, q.CreationDate, MIN(a.CreationDate)) AS DaysToFirstAnswer
FROM Posts q
JOIN Posts a ON q.Id = a.ParentId
WHERE q.PostTypeId = 1 -- 1 for Questions
  AND a.PostTypeId = 2 -- 2 for Answers
GROUP BY q.Id, q.Title, q.CreationDate
HAVING DATEDIFF(DAY, q.CreationDate, MIN(a.CreationDate)) > 1
ORDER BY DaysToFirstAnswer DESC;

Enter Parameters

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