Number of questions in Stack Overflow

0

Please login or register to vote for this query.

(click on this box to dismiss)

Mythology Meta

Q&A about the site for enthusiasts and scholars of mythology and folklore

-- Calculate number of questions per tag per year and total number of tags per year
WITH QuestionsPerTag AS (
    SELECT
        YEAR(p.CreationDate) AS Year,
        t.TagName,
        COUNT(*) AS QuestionsCount
    FROM
        Posts p
    JOIN
        PostTags pt ON p.Id = pt.PostId
    JOIN
        Tags t ON pt.TagId = t.Id
    WHERE
        p.PostTypeId = 1  -- Filter to include only questions 
        and
        t.TagName = 'telegram-bot'
    GROUP BY
        YEAR(p.CreationDate),
        t.TagName
),
TagsPerYear AS (
    SELECT
        YEAR(p.CreationDate) AS Year,
        COUNT(DISTINCT t.TagName) AS TotalTags
    FROM
        Posts p
    JOIN
        PostTags pt ON p.Id = pt.PostId
    JOIN
        Tags t ON pt.TagId = t.Id
    WHERE
        p.PostTypeId = 1  -- Filter to include only questions
    GROUP BY
        t.TagName, YEAR(p.CreationDate)
)
SELECT
    q.Year,
    q.TagName,
    q.QuestionsCount,
    t.TotalTags
FROM
    QuestionsPerTag q
JOIN
    TagsPerYear t ON q.Year = t.Year
GROUP BY
    q.Year,
    q.TagName,
    q.QuestionsCount,
    t.TotalTags

Enter Parameters

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