Score as function of Datalength of Post body weighted by number of questions

0

Please login or register to vote for this query.

(click on this box to dismiss)

Islam

Q&A for Muslims, experts in Islam, and those interested in learning more about Islam

-- Score as function of Datalength of Post body weighted by number of questions

WITH cte AS (
  SELECT 
    Ntile(10) OVER(ORDER BY Body_length ASC) * 10 AS 'Percentile', 
    Body_length,
    id FROM (
     SELECT
       id,
       Datalength(body) Body_length 
     FROM posts 
     WHERE  posttypeid = 2
   ) p) 
SELECT
  Percentile, 
  AVG(Body_length) AS 'Average Post Length',
  SUM(score) / COUNT(score) AS 'Average Votes per Post'
FROM posts p 
INNER JOIN cte 
 ON p.id = cte.id 
GROUP  BY Percentile 
ORDER  BY Percentile

Enter Parameters

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