% of upvotes as function of question length

1

Please login or register to vote for this query.

(click on this box to dismiss)

Mathematics

Q&A for people studying math at any level and professionals in related fields

DECLARE @IntervalLength INT;
SET @IntervalLength = 50;

SELECT (LEN(p.Body) / @IntervalLength) * @IntervalLength,
  100 * SUM(CASE v.VoteTypeId WHEN 2 THEN 1 ELSE 0 END) / COUNT(*) AS 'Upvote %'
  FROM Votes AS v
  INNER JOIN Posts AS p
    ON v.PostId = p.Id
  WHERE p.PostTypeId = 2 -- answers
    AND v.VoteTypeId IN (2, 3) -- up/downvotes
    AND p.CreationDate >= '2017-04-01'
  GROUP BY (LEN(p.Body) / @IntervalLength) * @IntervalLength
  ORDER BY (LEN(p.Body) / @IntervalLength) * @IntervalLength

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results