SELECT OwnerUserId, rating = AVG(CAST(number.score AS flo...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

SELECT 
OwnerUserId, rating = AVG(CAST(number.score AS float) /Max_score.mscore)*100, Answers_Count = COUNT(number.Score)
FROM 
    (SELECT OwnerUserId, ParentId, Score
  FROM Posts
  WHERE 
  PostTypeId = 2
  AND Score >0
  AND YEAR(CreationDate) <2011
  AND OwnerUserId IS NOT NULL) as number
 
 inner join
  
  (  SELECT 
ParentId, mscore = MAX(Score)
FROM 
POSTS
WHERE 
PostTypeId = 2
AND Score >1
AND YEAR(CreationDate) <2011
GROUP BY ParentId) as Max_score
on Max_score.ParentId = number.ParentId

GROUP BY OwnerUserId
HAVING 
OwnerUserId %2 = 0
ORDER BY OwnerUserId

Enter Parameters

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