Q&A about the site for members of the workforce navigating the professional setting
DECLARE @Tag1 nvarchar(max) = 'angularjs' DECLARE @Tag2 nvarchar(max) = 'knockout.js' DECLARE @1MonthsAgo datetime = DATEADD(month, -1, GETDATE()) DECLARE @2MonthsAgo datetime = DATEADD(month, -2, GETDATE()) DECLARE @3MonthsAgo datetime = DATEADD(month, -3, GETDATE()) -- Tag 1 Activity Last 3 months SELECT TagName, COUNT(*) AS Posts FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId where tagname = @Tag1 AND posts.creationdate > @1MonthsAgo group by tagname SELECT TagName, COUNT(*) AS Posts FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId where tagname = @Tag1 AND posts.creationdate > @2MonthsAgo and posts.creationdate < @1MonthsAgo group by tagname SELECT TagName, COUNT(*) AS Posts FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId where tagname = @Tag1 AND posts.creationdate > @3MonthsAgo and posts.creationdate < @2MonthsAgo group by tagname -- Tag 2 Activity Last 3 months SELECT TagName, COUNT(*) AS Posts FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId where tagname = @Tag2 AND posts.creationdate > @1MonthsAgo group by tagname SELECT TagName, COUNT(*) AS Posts FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId where tagname = @Tag2 AND posts.creationdate > @2MonthsAgo and posts.creationdate < @1MonthsAgo group by tagname SELECT TagName, COUNT(*) AS Posts FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId where tagname = @Tag2 AND posts.creationdate > @3MonthsAgo and posts.creationdate < @2MonthsAgo group by tagname