Worst posts in the last N days

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

set nocount on 
declare @BEGINDATE datetime
select @BEGINDATE = DateAdd(d, -##DaysAgo##, creationDate) from Posts where Id = (select max(Id) from Posts)
set nocount off

select top 50 A.id as [Post Link], B.score, A.creationDate
from Posts as A inner join (
  select postId, sum(case voteTypeId when 2 then 1 when 3 then -1 else 0 end) as score
  from Votes
  where creationDate > @BEGINDATE
  group by postId
  having sum(case voteTypeId when 3 then 1 when 2 then -1 else 0 end) > 0
) as B
on A.id = B.postId
where A.creationDate > @BEGINDATE
order by B.score

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results