Q&A about the site for gardeners and landscapers
select dateadd(m, datediff(m,0, Posts.CreationDate), 0) as month, cast(sum(case when votes.votetypeid = 2 then 1 else 0 end) as float) / Count(distinct Posts.Id) as upvotes_per_post, cast(sum(case when votes.votetypeid = 3 then 1 else 0 end) as float) / Count(distinct Posts.Id) as downvotes_per_post from Votes left outer join Posts on Posts.Id = Votes.PostId where (Votes.VoteTypeId = 2 or Votes.VoteTypeId = 3) and datediff(dd,Posts.CreationDate,Votes.CreationDate) <= 7 and dateadd(m, datediff(m,0, Posts.CreationDate), 0) < dateadd(m, datediff(m,0, getdate()), 0) group by dateadd(m, datediff(m,0, Posts.CreationDate), 0) order by dateadd(m, datediff(m,0, Posts.CreationDate), 0)