Activity During a Bounty Period

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

DECLARE @Year int = ##Year##

SELECT p.Id, p.PostTypeId, p.AcceptedAnswerId, p.CreationDate, p.Score,
       p.ViewCount, p.LastEditDate, p.LastActivityDate, p.Tags, 
       p.AnswerCount, p.CommentCount, p.FavoriteCount, p.ClosedDate, 
       bs.CreationDate AS BountyCreationDate, bs.BountyAmount,
       --DATEADD(day, 7, bs.CreationDate) AS BountyClose
       bc.CreationDate AS BountyCloseDate
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
      FROM Posts p
      JOIN Votes bc
        ON p.Id = bc.PostId
       AND bc.VoteTypeId = 9 -- BountyClose
) bc ON bc.id = p.id
WHERE YEAR(bs.CreationDate) = @Year
ORDER BY p.Id

Enter Parameters

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