Posts with many "thank you" answers

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

-- Now that we know who answers and the individual scores of those answers,
-- let's try to figure out who is most effective overall.  This query returns
-- the total score and name of each user who has answered our questions.

-- The key kere is the SUM in both the SELECT and the ORDER BY.  The
-- GROUP BY is still relevant becuase we want to have just one line per
-- answerer, but we no longer order by user name.

SELECT SUM(a.Score), COUNT(au.DisplayName), au.DisplayName

FROM Posts p 
JOIN Posts a ON p.Id = a.ParentId
JOIN Users au ON a.OwnerUserId = au.Id

WHERE p.PostTypeId = 1
  AND p.OwnerUserId = ##UserId##

GROUP BY au.DisplayName
ORDER BY SUM(a.Score) DESC

Enter Parameters

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