我目前在 SEDE 上创建了以下查询,以通过组合答案和得分计数来查找每个标签中的顶级用户。可以在这里找到:按分数和答案计数在所有标签中排名靠前的用户。但是,目前它正在为每个标签带回多个顶级用户,这是可以理解的,因为我还没有对此进行限制。
这是查询:
SELECT TOP 50
t.TagName,
a.OwnerUserId AS [User Link],
SUM(a.Score) / 10 AS Score,
COUNT(a.Score) AS [Count],
((SUM(a.Score) / 10) + COUNT(a.Score)) / 2 AS Total
FROM Posts a,
Posts q
INNER JOIN PostTags qt ON q.Id = qt.PostId
INNER JOIN Tags t ON t.Id = qt.TagId
WHERE a.ParentId = q.Id
AND a.PostTypeId = 2
AND a.CommunityOwnedDate IS NULL
AND a.OwnerUserId IS NOT NULL
GROUP BY a.OwnerUserId, t.TagName
ORDER BY ((SUM(a.Score) / 10) + COUNT(a.Score)) / 2 DESC
我怎样才能使它只返回每个标签的顶级用户?