Top UK users by quant tag and location

0

Please login or register to vote for this query.

(click on this box to dismiss)

Vegetarianism

Q&A for those committed to a vegan or vegetarian lifestyle and anyone interested in learning more

-- Top users by tag and location
-- Currently only looking at score for questions.  Not sure how to fix this yet.

--SELECT TOP 20 * FROM Posts


SELECT us.*,tuser.Score, tuser.TagName
FROM Users us
JOIN 
(SELECT Answers.OwnerUserId AS UserId, SUM(Answers.Score) AS Score, Tags.TagName
     FROM Tags 
    JOIN PostTags ON Tags.Id = PostTags.TagId
    JOIN Posts ON Posts.Id = PostTags.PostId  
    JOIN Posts Answers ON Answers.ParentId = Posts.Id 
    WHERE Tags.TagName 
    IN ('c#','.net')
  GROUP BY Answers.OwnerUserId, Tags.TagName
) tuser ON tuser.UserId = us.Id
WHERE
lower(location) like '%lisbon%' or
(lower(location) like '%lisbon%' 
and lower(location) not like '%new england%'
) 
or
(lower(location) like '%lisbon%' 
and lower(location) not like 'london%on' 
and lower(location) not like '%ontario%'
and lower(location) not like '%canada%'
)
or
(lower(location) like '%lisbon%' 
and lower(location) not like '%ukraine%' )
or
lower(location) like '%lisbon%'
or
lower(location) like '%sintra%'

ORDER BY us.Id, tuser.TagName

Enter Parameters

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