I'm trying to construct a query to find open questions with open bounties above a particular size.
Questions that either currently have or previously had bounties can be found on data.stackexchange.com by looking for associated Votes
records with a VoteTypeId
of 8
(= BountyStart
).
The problem is when trying to restrict these to ensure the bounty hasn't already been awarded or closed.
Can think of two possible ways:
- Look for questions with no associated
Vote
record with aVoteTypeId
of9
(= BountyClose
). - Bounties last for a week so restrict the
BountyOpen
records to those with aCreationDate
under a week ago:WHERE DATEADD(d, 7, vob.CreationDate) >= GETDATE()
But neither appears to be eliminating all questions where the bounty has ended. E.g. at the time of writing, only 2 of the 5 questions returned by this query (which includes both criteria) have an open bounty.
Am I missing something? Is there another way?