DECLARE @Subject NVARCHAR(35) = LOWER('python'); -- speci...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Korean Language

Q&A for linguists, teachers and students of the Korean language

DECLARE @Subject NVARCHAR(35) = LOWER('python'); -- specify the subject

SELECT TOP 10
    Users.Id AS UserId,
    Users.DisplayName,
    COUNT(*) AS AcceptedAnswersCount  
FROM Users
    INNER JOIN Posts AS Answers ON Users.Id = Answers.OwnerUserId 
    INNER JOIN Posts AS Questions ON Answers.ParentId = Questions.Id
    INNER JOIN PostTags ON Questions.Id = PostTags.PostId
    INNER JOIN Tags ON PostTags.TagId = Tags.Id
WHERE Tags.TagName = @Subject
    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; -- Sorting by users with the most accepted answers

Enter Parameters

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