Time to accepted answer

1

Please login or register to vote for this query.

(click on this box to dismiss)

First answer Last answer Accepted answer Highest-scored answer Date asked Date first answered Date accepted answer Answered by

Stack Overflow

Q&A for professional and enthusiast programmers

WITH
    Answers AS (
        SELECT *
            FROM Posts
            WHERE PostTypeId = 2 -- Answers
    )
SELECT TOP ##NumberOfQuestions:int?10000##
        --Question
        'http://stackoverflow.com/questions/' + CAST(Questions.Id AS NVARCHAR) AS [Post Link],
        
        --Date asked
        Questions.CreationDate AS [Date asked],
        
        --Accepted answer date
        AcceptedAnswer.CreationDate AS [Accepted answer],
        
        --Answered by
        'http://stackoverflow.com/users/' + CAST(AcceptedAnswer.OwnerUserId AS NVARCHAR) + '|' + CAST(AcceptedAnswer.OwnerUserId AS NVARCHAR) AS [Answered by],
        
        --Accepted answer score
         AcceptedAnswer.Score AS [Accepted answer score],
         
        --Time to accepted answer
        'http://stackoverflow.com/questions/' + CAST(AcceptedAnswer.Id AS NVARCHAR) + '|' + CAST(DATEDIFF(mi, Questions.CreationDate, AcceptedAnswer.CreationDate) AS NVARCHAR) AS [Minutes to Accepted Answer],

        --Time to accepted answer [text]
        CAST(DATEDIFF(mi, Questions.CreationDate, AcceptedAnswer.CreationDate) AS NVARCHAR) AS [Minutes to Accepted Answer Text]


        --Question score
        --Questions.Score AS [Q Score],
        
        --Time to first answer
        --'http://stackoverflow.com/questions/' + CAST(FirstAnswer.Id AS NVARCHAR) + '|' + CAST(DATEDIFF(mi, Questions.CreationDate, FirstAnswer.CreationDate) AS NVARCHAR) AS [Minutes to First Answer],
        
        --Date first answer
        --FirstAnswer.CreationDate AS [First answered]

    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        
    WHERE
        Questions.PostTypeId = 1 -- Questions
        and Tags.TagName in 
          ('vsts') 
        AND FirstAnswer.Id = (
            SELECT TOP 1 Id
                FROM Answers
                WHERE
                    Answers.ParentId = Questions.Id
                --ORDER BY CreationDate ASC
        )
;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results