Question count over time by tag comparison

1

Please login or register to vote for this query.

(click on this box to dismiss)

Compare the number of questions created by time for up to 4 tags.

Stack Overflow

Q&A for programmers

-- Tag1: Tag name (lowercase) or 'NA' (uppercase) "Enter a tag name or uppercase NA or a single space"
-- Tag2: Tag name (lowercase) or 'NA' (uppercase) "Enter a tag name or uppercase NA or a single space"
-- Tag3: Tag name (lowercase) or 'NA' (uppercase) "Enter a tag name or uppercase NA or a single space"
-- Tag4: Tag name (lowercase) or 'NA' (uppercase) "Enter a tag name or uppercase NA or a single space"
DECLARE @Tag1 varchar(255)  = ##Tag1:string##;
DECLARE @Tag2 varchar(255)  = ##Tag2:string##;
DECLARE @Tag3 varchar(255)  = ##Tag3:string##;
DECLARE @Tag4 varchar(255)  = ##Tag4:string##;


SELECT      DATEADD (month, DATEDIFF (month, 0, q.CreationDate), 0) AS [Month],
            t.TagName       AS [Tag],
            COUNT (q.Id)    AS Questions

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 (@Tag1, @Tag2, @Tag3, @Tag4)

GROUP BY    DATEADD (month, DATEDIFF (month, 0, q.CreationDate), 0),
            t.TagName
ORDER BY    t.TagName, [Month]

Enter Parameters

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