Recent bounties

1

Please login or register to vote for this query.

(click on this box to dismiss)

Returns all the past N questions with bounties, along with some basic stats about them. 'Closed' bounties were not awarded to any answer, for whatever reason.

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT TOP ##number?100##
  --number: Number of questions to query: 
  p.Id AS [Post Link],
  p.Score AS 'Score',
  p.AnswerCount AS 'Answers',
  bs.BountyAmount AS 'Amount',
  convert(varchar(10), bs.CreationDate, 120) AS 'Bounty Start',
  convert(varchar(10), bc.CreationDate, 120) AS 'Bounty Close',
  (CASE WHEN bc.Id IS NULL THEN 'Active' 
        WHEN bc.parentid IS NOT NULL THEN 'Awarded'
        ELSE 'Closed' END) AS 'Status'
        ,
  (CASE WHEN bc.parentid IS NOT NULL THEN bc.answerid 
        ELSE NULL END) AS [Post Link]
FROM Posts p
INNER JOIN Votes bs
    ON p.Id = bs.PostId
    AND bs.VoteTypeId = 8  -- BountyStart
LEFT OUTER JOIN ( 
    SELECT COALESCE(p.ParentId, p.Id) AS id,
           bc.CreationDate, 
           p.ParentId AS parentid,
           p.Id AS answerid
      FROM Posts p
      JOIN Votes bc
        ON p.Id = bc.PostId
       AND bc.VoteTypeId = 9 -- BountyClose
) bc ON bc.id = p.id
ORDER BY bs.CreationDate DESC

Enter Parameters

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