Distribution of voting activity in time for different vintages of questions and answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Amateur Radio

Q&A for amateur radio enthusiasts

With a as
(  -- select votes with date of post and vote
   Select
   p.Id,
   DATEPART(YYYY, p.CreationDate) PostYr, 
   DATEPART(YYYY, v.CreationDate) +
      1.00*DATEPART(m, v.CreationDate)/12 VoteMonth 
   from Posts p join Votes v 
                on p.Id = v.PostId 
   where p.PostTypeId in (1)
     and v.VoteTypeId in (2,3)
     and DATEPART(YYYY, p.CreationDate) in (2010,2012,2014,2016,2018)  
), b as 
(  -- select posts with date
   Select
   Id,
   DATEPART(YYYY, CreationDate) PostYr, 
   DATEPART(YYYY, CreationDate) +
      1.00*DATEPART(m, CreationDate)/12 PostMonth 
   from Posts 
   where PostTypeId in (1)
   and DATEPART(YYYY, CreationDate) in (2010,2012,2014,2016,2018)
), c as 
(  -- count of number of votes in some month
   Select PostYr,
          VoteMonth,
          count(Id) as SumMonthVotes
   from a
   group by PostYr, VoteMonth
), d as 
(  -- count of number of posts untill some month
   Select b.PostMonth, 
          b.PostYr,
          count(b.Id) over (partition by b.PostYr order by c.VoteMonth) as CumPosts
   from b full outer join c on b.PostMonth = c.VoteMonth
)


Select * from c
---Select PostMonth, Cast(PostYr as char), CumPosts from d

Enter Parameters

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