Score as function of Datalength of Post body

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

WITH cte AS (
  SELECT 
    Ntile(10) OVER(ORDER BY Body_length ASC) AS 'Bucket', 
    Body_length,
    id FROM (
     SELECT
       id,
       Datalength(body) Body_length 
     FROM posts 
     WHERE  posttypeid = 2
   ) p) 
SELECT
  bucket, 
  AVG(Body_length),
  SUM(score) / COUNT(score)
FROM posts p 
INNER JOIN cte 
 ON p.id = cte.id 
GROUP  BY bucket 
ORDER  BY bucket

Enter Parameters

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