What's going up, what's going down

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select top 1000 t.id tagId, t.tagName,  
  sum (case when year(p.creationDate) = 2012 then 1 else 0 end) TagUsage2012, 
  sum (case when year(p.creationDate) = 2013 then 1 else 0 end) TagUsage2013,   
  sum (case when year(p.creationDate) = 2014 then 1 else 0 end) TagUsage2014,   
  sum (case when year(p.creationDate) = 2015 then 1 else 0 end) TagUsage2015, 
  sum (case when year(p.creationDate) = 2016 then 1 else 0 end) TagUsage2016, 
  excerptPost.body
  from tags t
  join PostTags pTags on pTags.tagId = t.id
  join Posts p on pTags.postId = p.id
  join Posts excerptPost on excerptPost.id = t.excerptPostId
  
  where year(p.creationDate) in (2012, 2013, 2014, 2015, 2016) 
--   AND p.commentCount + p.answerCount > 0
  AND  p.PostTypeId = 1 -- questions 
  group by t.Id, t.tagName, excerptPost.body
  order by TagUsage2016 desc

Enter Parameters

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