HuntingBugsInBountyJoins

0

Please login or register to vote for this query.

(click on this box to dismiss)

Code Review

Q&A for peer programmer code reviews

with Awards as (
    select ParentId,
           OwnerUserId,
           Posts.Id as Id,
           Votes.Id as VotesId,
           BountyAmount
    from Posts, Votes
    where Posts.Id = Votes.PostId
      and PostTypeId = 2
      and VoteTypeId = 9
  )
select u.DisplayName as Sponsor,
       q.OwnerUserId as AskerID,
       bo.Id as BountyOfferID,
       bo.BountyAmount as BountyOfferAmount,
       bc.OwnerUserId as [User Link],
       bc.Id as [Post Link],
       bc.VotesId as BountyReceiveID,
       bc.BountyAmount as BountyReceiveAmount
from posts q
     inner join votes bo on q.id = bo.PostId
     inner join users u on u.id = bo.UserId
     left join Awards bc on q.Id = bc.ParentId
where bo.UserId in (9357,11227)
  and bo.VoteTypeId = 8
  and q.OwnerUserId != u.Id
  and q.PostTypeId = 1

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results