What is the answers/questions reputation ratio?

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

WITH T AS 
(
select 
p.OwnerUserId,
Q = ISNULL(SUM(CASE WHEN posttypeid = 1 THEN CASE VoteTypeId WHEN 2 THEN 5 WHEN 3 THEN -2 END END),0), 
A = ISNULL(SUM(CASE WHEN posttypeid = 2 THEN CASE VoteTypeId WHEN 2 THEN 10 WHEN 3 THEN -2 ELSE 15 END END),0) 
from posts p
join votes v on v.postid = p.id
where posttypeid in (1 --question
                   ,2) --answer
                   and votetypeid in (1 --accept
                                     ,2 -- up
                                     ,3) --down
group by p.OwnerUserId
)
SELECT ROUND(CAST(A AS FLOAT)/NULLIF(Q,0),0), COUNT(*)
FROM T
GROUP BY ROUND(CAST(A AS FLOAT)/NULLIF(Q,0),0)
ORDER BY 1

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results