17

I'm trying to create a query to check for the highest awarded bounties, but I can't seem to figure out how to do it.

I've tried this:

SELECT TOP 10
Posts.Id [Post Link], Score, BountyAmount
FROM
    Posts, Votes
ORDER BY BountyAmount Desc

But it isn't giving me the desired result. What am I missing?

0

1 Answer 1

18

These are the answers that earned the most reputation with bounties:

SELECT TOP 100
   SUM(V.BountyAmount) as 'Bounty Amount',
   COUNT(*) as 'Amount of Bounties',
   V.PostId AS [Post Link]
FROM
   Votes V 
INNER JOIN Posts P ON P.id = V.PostId
WHERE
   P.PostTypeId = 2 AND V.VoteTypeId=9 
GROUP BY V.PostId
ORDER BY 'Bounty Amount' DESC

And these are the questions where most reputation has been spent in bounties:

SELECT TOP 100
   SUM(V.BountyAmount) as 'Bounty Amount',
   COUNT(*) as 'Amount of Bounties',
   V.PostId AS [Post Link]
FROM
   Votes V 
INNER JOIN Posts P ON P.Id = V.PostId
WHERE
   P.PostTypeId = 1 AND V.VoteTypeId=8 
GROUP BY V.PostId
ORDER BY 'Bounty Amount' desc
1
  • 1
    You failed to mention what the asker was missing. Namely a join-condition, a sum, and a grouping.
    – jpmc26
    Commented Feb 14, 2019 at 0:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .