question score as function of question length

0

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 'Answer length',
  CAST(SUM(p.Score) AS float) / SUM(1.0) AS 'Average score'
  FROM Posts AS p
  WHERE p.PostTypeId = 1 -- questions
    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