Find tag badge owners from your city

1

Please login or register to vote for this query.

(click on this box to dismiss)

Chess

Q&A for serious players and enthusiasts of chess

DECLARE @myUsers TABLE
(
Id int,
Reputation int,
CreationDate datetime,
DisplayName nvarchar(40), 
LastAccessDate datetime, 
WebsiteUrl nvarchar(200),
Location nvarchar(100), 
AboutMe nvarchar(max), 
Views int,
UpVotes int,
DownVotes int,
ProfileImageUrl nvarchar (200),
EmailHash varchar (32),
AccountId int
)

DECLARE @myBadges TABLE
(
Id int,
UserId int,
Name nvarchar (50),
Date datetime,
Class tinyint,
TagBased bit
)

INSERT INTO @myBadges (Id, UserId, Name, Date, Class, TagBased)
SELECT Id, UserId, Name, Date, Class, TagBased
FROM Badges b
WHERE UPPER(b.name) LIKE UPPER('%' + ##Tag:string## + '%') AND b.TagBased = 1 /* AND Class < ( ##Class:int## + 1) */


INSERT INTO @myUsers (Id,  Reputation, CreationDate, DisplayName, LastAccessDate, WebsiteUrl, Location, AboutMe, 
Views, UpVotes, DownVotes, ProfileImageUrl, EmailHash,  AccountId)
SELECT Id, Reputation, CreationDate, DisplayName, LastAccessDate, WebsiteUrl, Location, AboutMe, 
Views, UpVotes, DownVotes, ProfileImageUrl, EmailHash,  AccountId
FROM Users u
WHERE u.Id IN (SELECT UserId FROM @myBadges)

SELECT * FROM @myUsers where lower(Location) like lower('%##Location##%') ORDER BY Reputation DESC

Enter Parameters

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