Tag Leaderboard for Answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Who are the top answerers for a given tag?

Christianity

Q&A for committed Christians, experts in Christianity and those interested in learning more

-- Tag Leaderboard for Answers
-- Who are the top answerers for a given tag?

DECLARE @TagName NVARCHAR(25) = '##TagName##';
DECLARE @MinimumScore INT = ##MinimumScore##;

SELECT
    ROW_NUMBER() OVER(ORDER BY SUM(a.Score) DESC) AS [#], 
    a.OwnerUserId AS [User Link], 
    SUM(a.Score) AS [Total Score]
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 t.TagName = @TagName
GROUP BY
    a.OwnerUserId
    HAVING SUM(a.Score) >= @MinimumScore;

Enter Parameters

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