Active bounties in a tag

0

Please login or register to vote for this query.

(click on this box to dismiss)

Lists all posts that have had a bounty opened

Stack Overflow

Q&A for professional and enthusiast programmers

CREATE TABLE #BountyQuestion (Id int)
INSERT #BountyQuestion
SELECT Posts.Id
FROM Posts
    INNER JOIN Votes             ON Posts.Id       = Votes.PostId
    INNER JOIN PostTags          ON Posts.Id       = PostTags.PostId
    INNER JOIN Tags              ON PostTags.TagId = Tags.id
WHERE   Posts.PostTypeId         = 1         -- PostTypeId = 1 ->Question
    AND Votes.VoteTypeId         = 8         -- VoteTypeId = 8 -> BountyStart
    AND Tags.TagName   = '##TagName##'
    AND DateDiff(day,Votes.CreationDate,GetDate())<8

SELECT Id AS [Post Link] FROM #BountyQuestion
EXCEPT 
SELECT Id AS [Post Link] FROM #BountyQuestion
WHERE NOT 9 IN (                             -- VoteTypeId = 9 -> BountyClose
             SELECT Votes.VoteTypeId FROM Votes, Posts Answers 
                WHERE Votes.PostId = Answers.Id
                AND Answers.ParentId=#BountyQuestion.Id
            )

Enter Parameters

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