Moderator election badges

1

Please login or register to vote for this query.

(click on this box to dismiss)

Artificial Intelligence

Q&A for people interested in conceptual questions about life and challenges in a world where "cognitive" functions can be mimicked in purely digital environment

select distinct
       bdg.[Name]
  into #ModeratorElectionBadges
  from [Badges] bdg
 where bdg.[Name] in (
         'Civic Duty', 
         'Cleanup',
         'Constituent',
         'Convention',
         'Copy Editor',
         'Deputy',
         'Electorate',
         'Enthusiast',
         'Explainer',
         'Investor',
         'Marshal',
         'Organizer',
         'Quorum',
         'Refiner',
         'Reviewer',
         'Sportsmanship',
         'Steward', 
         'Strunk & White',
         'Tag Editor',
         'Yearling'
);

select distinct
       usr.[Id]   as [UserId],
       bdg.[Name] as [BadgeName]
  into #UserModeratorElectionBadges
  from [Users]  usr
           join
       [Badges] bdg on bdg.[UserId] = usr.[Id]
                   and bdg.[Name] in (select [Name] from #ModeratorElectionBadges)
 where usr.[Id] in ( ##UserIds## );

select distinct
       usr.[Id],
       bdg.[Name],
       iif(ume.[UserId] is null, 0, 1) as [HasBadge]
  from #ModeratorElectionBadges     meb
           join
       [Badges]                     bdg on bdg.[Name]      = meb.[Name]
           left join
       #UserModeratorElectionBadges ume on ume.[BadgeName] = meb.[Name]
           join
       [Users]                      usr on usr.[Id]        = ume.[UserId]
 order by bdg.[Name];

/*
select distinct
       ume.[UserId],
       bdg.[Name],
       iif(ume.[UserId] is null, 0, 1) as [HasBadge]
  from #ModeratorElectionBadges     meb
           join
       [Badges]                     bdg on bdg.[Id]      = meb.[Id]
           left join
       #UserModeratorElectionBadges ume on ume.[BadgeId] = meb.[Id]
 order by bdg.[Name];
*/

Enter Parameters

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