Citizenship score for the users from a list (with breakdown by specific badges)

1

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Different

Q&A for power users of Apple hardware and software

With prelim As 
(
   Select u.Id As Username, 
      floor(10+0.5*u.Reputation/1000-0.5*abs(u.Reputation/1000-20)) As CappedRep, 
      Count(distinct b.Name) As BadgeCount, 
      u.LastAccessDate As LastAccess,
      SUM(case when b.Name = 'Civic Duty' then 1 else 0 end) AS CivicDuty,
      SUM(case when b.Name = 'Cleanup' then 1 else 0 end) AS Cleanup,
      SUM(case when b.Name = 'Constituent' then 1 else 0 end) AS Constituent,
      SUM(case when b.Name = 'Convention' then 1 else 0 end) AS Convention,
      SUM(case when b.Name = 'Copy Editor' then 1 else 0 end) AS CopyEditor,
      SUM(case when b.Name = 'Deputy' then 1 else 0 end) AS Deputy,
      SUM(case when b.Name = 'Electorate' then 1 else 0 end) AS Electorate,
      SUM(case when b.Name = 'Enthusiast' then 1 else 0 end) AS Enthusiast,
      SUM(case when b.Name = 'Explainer' then 1 else 0 end) AS Explainer,
      SUM(case when b.Name = 'Investor' then 1 else 0 end) AS Investor,
      SUM(case when b.Name = 'Marshal' then 1 else 0 end) AS Marshal,
      SUM(case when b.Name = 'Organizer' then 1 else 0 end) AS Organizer,
      SUM(case when b.Name = 'Quorum' then 1 else 0 end) AS Quorum,
      SUM(case when b.Name = 'Refiner' then 1 else 0 end) AS Refiner,
      SUM(case when b.Name = 'Sportsmanship' then 1 else 0 end) AS Sportsmanship,
      SUM(case when b.Name = 'Strunk & White' then 1 else 0 end) AS StrunkWhite,
      SUM(case when b.Name = 'Tag Editor' then 1 else 0 end) AS TagEditor,
      SUM(case when b.Name = 'Reviewer' then 1 else 0 end) AS Reviewer,
      SUM(case when b.Name = 'Steward' then 1 else 0 end) AS Steward,
      SUM(case when b.Name = 'Yearling' then 1 else 0 end) AS Yearling
   From Users u
   Inner Join Badges b On b.UserId = u.Id
   Where u.Reputation >= ##min?1000## and 
     u.Id in (##list?5101,7206,20302,45250,80790,92164,120914##) and
     b.Name in (
         'Civic Duty', 
         'Cleanup',
         'Constituent',
         'Convention',
         'Copy Editor',
         'Deputy',
         'Electorate',
         'Enthusiast',
         'Explainer',
         'Investor',
         'Marshal',
         'Organizer',
         'Quorum',
         'Refiner',
         'Sportsmanship',
         'Strunk & White',
         'Tag Editor',
         'Reviewer',
         'Steward', 
         'Yearling')
  Group By u.Id, u.Reputation, u.LastAccessDate
) 
  
Select Username as [User Link], CappedRep+BadgeCount as Total, CappedRep, BadgeCount, LastAccess,
  CivicDuty, Cleanup, Constituent, Convention, CopyEditor, Deputy, Electorate, Enthusiast, 
  Explainer, Investor, Marshal, Organizer, Quorum, Refiner, Sportsmanship, StrunkWhite, TagEditor, Reviewer, Steward, Yearling

From prelim 
Order By Total desc

Enter Parameters

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