List bounties won by tag names

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

-- Bounties Won

DECLARE @TagName1 nvarchar(25) = ##Tag1:string##
DECLARE @TagName2 nvarchar(25) = ##Tag2:string##
DECLARE @TagName3 nvarchar(25) = ##Tag3:string##

SELECT 
  p.Id As [Post Link], 
  SUM(v.BountyAmount) As BountyWon, 
  p.Tags AS PostTags
FROM Votes v
  JOIN Posts p ON v.PostId = p.Id 
  JOIN PostTags pt ON pt.PostId = p.Id 
  JOIN Tags t ON t.Id = pt.TagId
WHERE
  (t.TagName = @TagName1 
  OR t.TagName = @TagName2 
  OR t.TagName = @TagName3)
  AND v.BountyAmount > 0
GROUP BY
  p.Id, p.Tags
ORDER BY
  BountyWon DESC

Enter Parameters

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