Question Count or Score growth over time by tag comparison


Please login or register to vote for this query.

(click on this box to dismiss)

Plots total questions over time or total score over time, comparing up to 4 tags. Reference:

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @ShowScore INT      = 1;

WITH QuestStatsByMonth  AS (
    SELECT      DATEADD (month, DATEDIFF (month, 0, q.CreationDate), 0)  AS [Month],
    SUM (q.Score)               AS TotalScore,
    COUNT (q.Id)                AS NumQuests

    FROM        Posts           q
    INNER JOIN  PostTags        pt
    ON          q.Id            = pt.PostId
    INNER JOIN  Tags            t
    ON          t.Id            = pt.TagId

    WHERE       q.PostTypeId    = 1
    AND         t.TagName       IN ('angular', 'reactjs', 'jquery')

    GROUP BY    DATEADD (month, DATEDIFF (month, 0, q.CreationDate), 0),
    CASE    @ShowScore
        WHEN    1 THEN  q.TagName + ' score'
        ELSE            q.TagName + ' questions'
    END AS [Tag],

    CASE    @ShowScore
        WHEN    1 THEN  SUM (h.TotalScore)
        ELSE            SUM (h.NumQuests)
    END AS Cumulative

FROM        QuestStatsByMonth   q
LEFT JOIN   QuestStatsByMonth   h
ON          h.[Month]           = q.[Month]
AND         h.TagName           = q.TagName
GROUP BY    q.[Month], q.TagName
ORDER BY    q.[Month], q.TagName

Enter Parameters

Switch to meta site
loading Hold tight while we fetch your results