Posts that are one upvote away from earning you "Necromancer"

0

Please login or register to vote for this query.

(click on this box to dismiss)

Returns a list of questions for a given user that have 4 upvotes and are at least 60 days old, meaning the next upvote on any of the posts will earn the user a Necromancer badge.

Christianity

Q&A for committed Christians, experts in Christianity and those interested in learning more

-- Posts that are one upvote away from earning you "Necromancer"
-- Returns a list of questions for a given user that have 4 upvotes and are at least 60 days old, meaning the next upvote on any of the posts will earn the user a Necromancer badge.

declare @userId int = ##userId##

select
    p.ParentId as [Post Link]
   ,datediff(day, p.CreationDate, GETDATE()) as [Days Old]
   ,count(*) as voteCount
from
    Posts p         
    inner join Votes v
        on v.PostId = p.Id
        and v.VoteTypeId = 2
where
    p.OwnerUserId = @userId
    and datediff(day, p.CreationDate, GETDATE()) >= 60
group by
    p.ParentId
   ,p.Id
   ,datediff(day, p.CreationDate, GETDATE())
having
    count(*) = 4
order by
    datediff(day, p.CreationDate, GETDATE()) desc
   

Enter Parameters

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