Q&A for professional and enthusiast programmers
SELECT COUNT( DISTINCT p.id) QuestionWithBounty, COUNT( DISTINCT Answer.id) BountyAnswers, SUM(CASE WHEN PostsBeforeBounty.Id is null THEN 1 ELSE 0 END) FirstTimePosts FROM posts P INNER JOIN Votes bStart ON p.id = bStart.PostID AND bStart.VoteTypeID = 8 INNER JOIN Posts Answer ON Answer.ParentID = p.ID and Answer.CreationDate > bStart.CreationDate --Answers after bount LEFT JOIN Posts PostsBeforeBounty ON Answer.OwnerUserId = PostsBeforeBounty.OwnerUserID and Answer.CreationDate > PostsBeforeBounty.CreationDate