Comparing 3 tags month over month since March 2016. Note: If you want to have one or two tags, set the same tags for both fields
Q&A about the site for followers of the Hindu religion and those interested in learning more about Hinduism
create table #tags (Date date, TagName nvarchar (35), Count int); insert into #tags select DATEADD(Month, DATEDIFF(Month, 0, CreationDate), 0) AS [Month], t.TagName, count(*) as Count from Posts p join PostTags pt on pt.PostId = p.Id join Tags t on t.Id = pt.TagId where p.CreationDate > '2016-03-01' AND (t.TagName = ##Tag1:string?angularjs##) or (t.TagName = ##Tag2:string?javascript##) or (t.TagName = ##Tag3:string?wpf##) group by t.TagName, DATEADD(Month, DATEDIFF(Month, 0, CreationDate), 0) order by [MONTH] desc; select * from #tags where TagName in ( select TOP 10 TagName from #tags where Date in ( select TOP 10 Date from #tags order by Date desc ) order by Count desc ) order by [Date] asc;