Answer score by post length

1

Please login or register to vote for this query.

(click on this box to dismiss)

Groups posts of varying length together by answer score for a given user.

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @UserId int = ##UserId##

SELECT 
p.Score as AnswerScore,
sum(case when len(p.body) <= 200 then 1 else 0 end) as PostsWithLen_0_200,
sum(case when len(p.body) between 201 and 500 then 1 else 0 end) as PostsWithLen_201_500,
sum(case when len(p.body) between 501 and 1000 then 1 else 0 end) as PostsWithLen_501_1000,
sum(case when len(p.body) between 1001 and 2000 then 1 else 0 end) as PostsWithLen_1001_2000,
sum(case when len(p.body) > 2001 then 1 else 0 end) as PostsWithLen_2001plus
    
FROM
    Posts p
WHERE
    p.OwnerUserId = @UserId
  AND
    p.PostTypeId = 2
group by p.Score

Enter Parameters

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