Answer votes per week

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

declare @epoch date = '2008-11-15';

select cast(dateadd(week, datediff(week, @epoch, v.CreationDate), @epoch) as DATE) Week,
       case VoteTypeId when 1 then 'Accept' when 2 then 'Up' when 3 then 'Down' end,
       count(*)
from Votes v
     join Posts p on v.PostId = p.Id
where v.CreationDate > @epoch
      --v.CreationDate between '2011-05-01' and '2014-05-01' --getdate()
      and PostTypeId = 2
      and VoteTypeId in (1,2,3)
group by datediff(week, @epoch, v.CreationDate), VoteTypeId
order by datediff(week, @epoch, v.CreationDate)

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached