Trendy tags: 2015 to 2016 growth

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 30 *, cast(100.0 * (a.y2016 - a.y2015)/nullif(a.y2015, 0) as decimal (18, 2)) as growth  from 
( 
  select 
  t.TagName, count(distinct p.id) as postCount,   
    sum(CASE WHEN year(p.CreationDate) = 2014 THEN 1 ELSE 0 END) as y2014,     
    sum(CASE WHEN year(p.CreationDate) = 2015 THEN 1 ELSE 0 END) as y2015, 
    sum(CASE WHEN year(p.CreationDate) = 2016 THEN 1 ELSE 0 END) as y2016
  from Posts p 
  join PostTags pTags on pTags.postId = p.id
  join Tags t on pTags.tagId = t.id
  where year(p.CreationDate) in (2015,2016, 2014)
  group by t.TagName
) as a 
where  a.y2014 >= ##Min2014## AND  1.0 * a.y2016 >= 1.25 * a.y2015 and a.postCount > ##MinQuestions##
order by growth desc

Enter Parameters

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