select upmod , downmod , datediff(d, first, last) , posti...

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)
     , postid
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(creationdate) as first
     , max(creationdate) as last
     , postid
from votes
group by postid
) as data
order by datediff(d, first, last) desc

Enter Parameters

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