Q&A for administrators and users of the CiviCRM Constituent Relationship Management software
select Count(Badges.Name) AS TotalBadge, DisplayName, MAX(Reputation) AS MaxReputation from Users Right Join Badges ON Users.AccountId = Badges.UserId where Location = 'South Africa' and name = 'Enlightened' and Badges.Date Between '2016-01-01 00:00:01' and '2016-12-31 00:00:00' GROUP BY DisplayName;