Average viewcount depending on the total amount of bounties on the question

0

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

;with bounties_cte AS (
SELECT 
  SUM(bs.BountyAmount) AS Amount,
  p.Id AS pid,
  p.ViewCount AS vc
FROM Posts p INNER JOIN Votes bs ON p.Id = bs.PostId
WHERE bs.VoteTypeId = 8  -- BountyStart
GROUP BY p.Id, p.ViewCount)


SELECT 
  Amount,
  AVG(CAST(vc AS decimal)) AS [Average Viewcount],
  COUNT(pid) [Number of posts]
FROM bounties_cte
GROUP BY Amount
ORDER BY Amount

Enter Parameters

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