% 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 = ##IntervalLength:int##;
DECLARE @MaximumLength INT; SET @MaximumLength = ##MaximumLength:int##;

SELECT (LEN(p.Body) / @IntervalLength) * @IntervalLength AS 'Post length',
  100.0 * 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 = 1 -- questions
    AND v.VoteTypeId IN (2, 3) -- up/downvotes
    AND LEN(p.Body) < @MaximumLength
  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