Q&A about the site for Ubuntu users and developers
-- *BONUS* For the questions created in 2017, what was the average time (in seconds) between when the question was created and when the accepted answer was provided?
;with questions_answered as (
year(creationdate) = 2017
and Acceptedanswerid is not null
qa.ID as 'QuestionID',
qa.CreationDate as 'Question_date',
p.ID as 'AnswerID',
p.Creationdate as 'Answer_date',
datediff(second, qa.CreationDate, p.Creationdate) as 'Response_time'
questions_answered qa on qa.AcceptedAnswerid = p.id
--Count(*) as 'NUmber of Questions Answered',
--AVG(Response_time) as 'AVG Response Time'