Q&A for committed Christians, experts in Christianity and those interested in learning more
select p.Id,count(vp.PostId) as upvote from Posts p left outer join (select pp.ParentId,max(pp.CreationDate) as maxcdate from Posts pp where pp.PostTypeId=2 group by pp.ParentId)pa on p.Id=pa.ParentId left outer join (select v.PostId,v.CreationDate from Votes v where v.VoteTypeId=2)vp on p.Id=vp.PostId where p.PostTypeId=1 and p.Id%500=358 and Year(p.CreationDate)=2019 and vp.CreationDate<maxcdate group by p.Id