DECLARE @TagToSearch nvarchar = ##tag:string## SELECT --...

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

DECLARE @TagToSearch nvarchar = ##tag:string##

SELECT --TOP 20 
    TagName,
    Users.Id AS [User Link],
    COUNT(*) AS UpVotes 
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
  Tags.TagName LIKE '%' + @TagToSearch + '%'
  AND (
    LOWER(Users.Location) LIKE '%poland%'
    OR UPPER(Users.Location) LIKE '%POLAND%'
    OR LOWER(Users.Location) LIKE '%polska%'
    OR LOWER(Users.Location) LIKE '%POLSKA%'
    OR Users.Location LIKE '%Polska%'
  )
  AND Users.Reputation >= 200
GROUP BY Tags.TagName , Users.Id
ORDER BY UpVotes DESC

Enter Parameters

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