DECLARE @Tag NVARCHAR(35) = LOWER('python'); -- specify t...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Music Fans Meta

Q&A about the site for music historians, critics, and fans

DECLARE @Tag NVARCHAR(35) = LOWER('python'); -- specify the tag

SELECT TOP 100
    Users.Id AS UserId,
    Users.DisplayName,
    COUNT(*) AS AcceptedAnswersCount  
FROM
    Users
JOIN
    Posts AS Answers ON Users.Id = Answers.OwnerUserId 
JOIN
    Posts AS Questions ON Answers.ParentId = Questions.Id
JOIN
    PostTags ON Questions.Id = PostTags.PostId
JOIN
    Tags ON PostTags.TagId = Tags.Id
WHERE
    Tags.TagName = @Tag
    AND Answers.PostTypeId = 2 -- Answers only
    AND Answers.Id = Questions.AcceptedAnswerId -- Accepted answers only
    AND Answers.CreationDate >= DATEADD(year, -1, GETDATE()) -- Within the last year
GROUP BY
    Users.Id, Users.DisplayName
ORDER BY
    AcceptedAnswersCount DESC;

Enter Parameters

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