Unawarded Bounties Count

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

WITH Awarded AS (
SELECT question.Id as PostId, COUNT(v.BountyAmount) as Awarded FROM Votes v 
INNER JOIN Posts p ON v.PostId = p.Id
INNER JOIN Posts question ON p.ParentID = question.Id
WHERE v.VoteTypeId = 9
GROUP BY question.Id
)
SELECT COUNT(v.BountyAmount) AS Offered, SUM(a.Awarded) AS Awarded FROM Votes v
INNER JOIN Posts p ON v.PostId = p.Id
LEFT JOIN Awarded a ON p.Id = a.PostId
WHERE v.VoteTypeId = 8
AND p.CreationDate BETWEEN '2012-01-01' AND '2012-09-30'

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached