Question up/down voting by time


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- Gotta ignore questions before the first (which were migrated in):
DECLARE @FirstQuestion datetime = (SELECT min(CreationDate) FROM Posts WHERE Id >= 1);

declare @epoch datetime = @FirstQuestion

select CAST(DATEADD(week, DATEDIFF(week, @epoch, p.CreationDate), @epoch) AS Date) week,
       count(case when VoteTypeId = 2 then 1 end)*1.0/count(*)
from Posts p
     join Votes v on PostId = p.Id
where PostTypeId = 1
      and VoteTypeId in (2, 3)
      and p.CreationDate > @FirstQuestion
group by DATEDIFF(week, @epoch, p.CreationDate)
order by DATEDIFF(week, @epoch, p.CreationDate)

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results