Answer votes per week


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast 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,
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

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