Number of Code Snippets vs Response Time

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers Meta

Q&A about the site for Drupal developers and administrators

WITH post_comments AS
(
    SELECT
        postid,
        MIN(creationdate) AS first_comment
    FROM comments
    GROUP BY postid
),
code_snippet_counts AS
(
    SELECT
        id AS post_id,
        (LEN(body) - LEN(REPLACE(body, '<code>', ''))) / LEN('<code>') AS code_snippet_count
    FROM posts
    WHERE
        CreationDate >= '2021-05-03'
        AND CreationDate <= '2021-05-10'
        AND (ClosedDate IS NULL OR ClosedDate <= '2021-05-10')
        AND posttypeid = 1  -- Ensure we are only considering questions (posttypeid = 1)
)
SELECT
    posts.id AS post_id,
    code_snippet_counts.code_snippet_count,
    DATEDIFF(minute, posts.CreationDate, post_comments.first_comment) AS response_time_in_minutes
FROM code_snippet_counts
INNER JOIN post_comments
    ON code_snippet_counts.post_id = post_comments.postid
INNER JOIN posts
    ON code_snippet_counts.post_id = posts.id;

Enter Parameters

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