Integration of new members: Average seniority in days between qr and ar for new member questions


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT result.Month,
       'Integration of new members' = AVG(result.Seniority)
      SELECT Question_id = answers.ParentId, 
              Month = DATEADD(MONTH, DATEDIFF(MONTH, 0, questions.CreationDate), 0), 
              Seniority = AVG(DATEDIFF(DAY, answerer.CreationDate, questioner.CreationDate))

      FROM Posts answers

      INNER JOIN Posts questions
          ON answers.ParentId = questions.Id

      INNER JOIN Users answerer
          ON answers.OwnerUserId = answerer.Id

      INNER JOIN Users questioner
          ON questions.OwnerUserId = questioner.Id

      WHERE answers.PostTypeId = 2 AND
            DATEDIFF(MONTH, questions.CreationDate, answers.CreationDate) < 1 AND
            DATEDIFF(MONTH, questioner.CreationDate, questions.CreationDate) < 1
      GROUP BY answers.ParentId, DATEADD(MONTH, DATEDIFF(MONTH, 0, questions.CreationDate), 0)
      ) AS result
GROUP BY result.Month
ORDER BY result.Month

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results