Score at time of post

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 sum(score) + 1
from
(select count(*) * p.posttypeid * 5 score
from posts p 
inner join votes v on v.postid = p.id
inner join posts p2 on p2.owneruserid = p.owneruserid
where p2.id = ##postid?8092417##
and v.votetypeid = 2
and p.creationdate < p2.creationdate
and v.creationdate < p2.creationdate
and p.posttypeid in (1, 2)
group by p.posttypeid
union all
select count(*) * -2
from posts p 
inner join votes v on v.postid = p.id
inner join posts p2 on p2.owneruserid = p.owneruserid
where p2.id = ##postid?8092417##
and v.votetypeid = 3
and p.creationdate < p2.creationdate
and v.creationdate < p2.creationdate
and p.posttypeid in (1, 2)
group by p.posttypeid) t

Enter Parameters

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