Time to answer (first answer, last answer, accepted answer, highest-scored answer)


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

    Answers AS (
        SELECT *
            FROM Posts
            WHERE PostTypeId = 2 -- Answers
SELECT TOP ##NumberOfQuestions:int##
        Questions.Id AS [Post Link],
        Questions.Score AS [Q Score],
        'site://a/' + CAST(FirstAnswer.Id AS NVARCHAR) + '|' + CAST(DATEDIFF(mi, Questions.CreationDate, FirstAnswer.CreationDate) AS NVARCHAR) AS [Minutes to First Ans],
        'site://a/' + CAST(AcceptedAnswer.Id AS NVARCHAR) + '|' + CAST(DATEDIFF(mi, Questions.CreationDate, AcceptedAnswer.CreationDate) AS NVARCHAR) AS [Minutes to Accepted Ans]
    FROM Posts AS Questions
        inner join PostTags
            on Questions.Id = PostTags.PostId
        inner join Tags 
            on PostTags.TagId = Tags.Id
        LEFT OUTER JOIN Answers AS FirstAnswer
            ON FirstAnswer.ParentId = Questions.Id
        LEFT OUTER JOIN Answers AS AcceptedAnswer
            ON AcceptedAnswer.Id = Questions.AcceptedAnswerId
        Questions.PostTypeId = 1 -- Questions
        and Tags.TagName in 
        AND FirstAnswer.Id = (
            SELECT TOP 1 Id
                FROM Answers
                    Answers.ParentId = Questions.Id
                ORDER BY CreationDate ASC

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results