Shows the trend for your favourite tag
Q&A for amateur radio enthusiasts
--DECLARE @TagName varchar(255) = '##TagName##'; DECLARE @PostCountByMonth TABLE ( [date] datetime, [totalCount] int, [##TagName##Count] int, UNIQUE CLUSTERED ([date]) ); INSERT INTO @PostCountByMonth SELECT dateadd(month, DATEDIFF(month, '', p.CreationDate), '') [date], count(*) [totalCount], count(p.[IsTag]) [##TagName##Count] FROM ( SELECT Posts.CreationDate, (case when Posts.Tags LIKE '%<##TagName##>%' then 1 else null end) [IsTag] FROM Posts WHERE Posts.PostTypeId = 1 ) p GROUP BY DATEDIFF(month, '', p.CreationDate) ORDER BY DATEDIFF(month, '', p.CreationDate); SELECT p1.[date], p1.[##TagName##Count] * 100.0 / p1.[totalCount] [Percentage of questions tagged <##TagName##>] FROM @PostCountByMonth p1 ORDER BY p1.[date]