select COUNT(CASE WHEN Posts.CreationDate < '2017-02-01' ...

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
COUNT(CASE WHEN Posts.CreationDate < '2017-02-01' and Posts.CreationDate >= '2017-01-01' then 1 ELSE NULL END) as jan17,
COUNT(CASE WHEN Posts.CreationDate < '2017-03-01' and Posts.CreationDate >= '2017-02-01' then 1 ELSE NULL END) as feb17,
COUNT(CASE WHEN Posts.CreationDate < '2017-04-01' and Posts.CreationDate >= '2017-03-01' then 1 ELSE NULL END) as mar17,
COUNT(CASE WHEN Posts.CreationDate < '2017-05-01' and Posts.CreationDate >= '2017-04-01' then 1 ELSE NULL END) as apr17,
COUNT(CASE WHEN Posts.CreationDate < '2017-06-01' and Posts.CreationDate >= '2017-05-01' then 1 ELSE NULL END) as may17,
COUNT(CASE WHEN Posts.CreationDate < '2017-07-01' and Posts.CreationDate >= '2017-06-01' then 1 ELSE NULL END) as jun17,
COUNT(CASE WHEN Posts.CreationDate < '2017-08-01' and Posts.CreationDate >= '2017-07-01' then 1 ELSE NULL END) as jul17,
COUNT(CASE WHEN Posts.CreationDate < '2017-09-01' and Posts.CreationDate >= '2017-08-01' then 1 ELSE NULL END) as aug17,
COUNT(CASE WHEN Posts.CreationDate < '2017-10-01' and Posts.CreationDate >= '2017-09-01' then 1 ELSE NULL END) as sep17,
COUNT(CASE WHEN Posts.CreationDate < '2017-11-01' and Posts.CreationDate >= '2017-10-01' then 1 ELSE NULL END) as oct17,
COUNT(CASE WHEN Posts.CreationDate < '2017-12-01' and Posts.CreationDate >= '2017-11-01' then 1 ELSE NULL END) as nov17,
COUNT(CASE WHEN Posts.CreationDate < '2018-01-01' and Posts.CreationDate >= '2017-12-01' then 1 ELSE NULL END) as dec17,
COUNT(CASE WHEN Posts.CreationDate < '2018-02-01' and Posts.CreationDate >= '2018-01-01' then 1 ELSE NULL END) as jan18,
COUNT(CASE WHEN Posts.CreationDate < '2018-03-01' and Posts.CreationDate >= '2018-02-01' then 1 ELSE NULL END) as feb18,
COUNT(CASE WHEN Posts.CreationDate < '2018-04-01' and Posts.CreationDate >= '2018-03-01' then 1 ELSE NULL END) as mar18,
COUNT(CASE WHEN Posts.CreationDate < '2018-05-01' and Posts.CreationDate >= '2018-04-01' then 1 ELSE NULL END) as apr18,
COUNT(CASE WHEN Posts.CreationDate < '2018-06-01' and Posts.CreationDate >= '2018-05-01' then 1 ELSE NULL END) as may18,
COUNT(CASE WHEN Posts.CreationDate < '2018-07-01' and Posts.CreationDate >= '2018-06-01' then 1 ELSE NULL END) as jun18,
COUNT(CASE WHEN Posts.CreationDate < '2018-08-01' and Posts.CreationDate >= '2018-07-01' then 1 ELSE NULL END) as jul18,
Tags.TagName

from Tags, PostTags, Posts p1, Posts

where Tags.Id = PostTags.TagId 
  and p1.Id = PostTags.PostId 
  and p1.Id = Posts.ParentId
  and Posts.PostTypeId = 2
  and Posts.CreationDate < '2018-08-01'
  and Posts.CreationDate >= '2017-01-01'

group by
  Tags.TagName

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results