select upmod , downmod , datediff(d, first, last) 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

select upmod
     , downmod
     , datediff(d, first, last) days
     , postid as [Post Link] 
from (
select sum(case when votetypeid = 2 then 1 else 0 end) as upmod
     , sum(case when votetypeid = 3 then 1 else 0 end) as downmod
     , min(v.creationdate) as first
     , max(v.creationdate) as last
     , postid
from votes v
inner join posts p on p.id = v.postid
where votetypeid in (2,3)
group by postid
having sum(case when votetypeid = 2 then 1 else 0 end) > 300 -- close vote
) as data
order by datediff(d, first, last) asc

Enter Parameters

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