Users Answers' Reputation Rank for Tag in Country

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow на русском Meta

Вопросы и ответы о сайте для программистов

SELECT users.Id AS [User Link], 
  SUM(CASE
      WHEN votes.VoteTypeId = 1 THEN 15 -- Accepted answer.
      WHEN votes.VoteTypeId = 2 AND answers.PostTypeId = 1 THEN 5 -- Upvoted question.
      WHEN votes.VoteTypeId = 2 AND answers.PostTypeId = 2 THEN 10 -- Upvoted answer.
      WHEN votes.VoteTypeId = 3 THEN -2 -- Downvote.
      WHEN votes.VoteTypeId = 9 THEN votes.BountyAmount -- Earned Bounty.
    END) AS [Score]
FROM Users users
  INNER JOIN Posts answers ON users.Id = answers.OwnerUserId
  INNER JOIN Posts posts ON answers.ParentId = posts.Id
  INNER JOIN PostTags postTags ON posts.Id = postTags.PostId
  INNER JOIN Tags tags ON postTags.TagId = tags.Id
  INNER JOIN Votes votes ON Votes.PostId = answers.Id
WHERE
  LOWER(users.Location) LIKE LOWER('%##country##%') AND
  tags.TagName = '##tagName##'
GROUP BY
  users.Id
ORDER BY [Score] DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results