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) as [TotalScore], COUNT(au.DisplayName) as [Number], 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