SELECT TOP 20 COUNT(*) AS UpVotes, Posts.OwnerUserId AS ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- How many upvotes do I have for each tag?
-- how long before I get tag badges?

SELECT TOP 20 
    COUNT(*) AS UpVotes, Posts.OwnerUserId AS [User Link]
FROM Tags
    INNER JOIN PostTags ON PostTags.TagId = Tags.id
    INNER JOIN Posts ON Posts.ParentId = PostTags.PostId
    INNER JOIN Votes ON Votes.PostId = Posts.Id and VoteTypeId = 2
    INNER JOIN Users ON Posts.OwnerUserId = Users.Id
    WHERE (TagName = 'c++' OR TagName = 'python') AND
    (
      UPPER(Users.Location) LIKE '%ITALY%' OR
      UPPER(Users.Location) LIKE '%ITALIA%' OR
      UPPER(Users.AboutMe) LIKE '%ITALY%' OR
      UPPER(Users.AboutMe) LIKE '%ITALIA%' OR
      UPPER(Users.Location) LIKE '%MILAN%' OR
      UPPER(Users.Location) LIKE '%VIGEVANO%'
    )
GROUP BY Posts.OwnerUserId
ORDER BY UpVotes DESC

Enter Parameters

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