Count of badges on user page?

I’m looking for an all time count, so thanks to your direction I pulled this query from the user_stat.rb and ran it in the data explorer and it gave me a list of all users with their badge count:

SELECT users.id user_id, COUNT(distinct user_badges.badge_id) distinct_badge_count
        FROM users
        LEFT JOIN user_badges ON user_badges.user_id = users.id
                              AND (user_badges.badge_id IN (SELECT id FROM badges WHERE enabled))
        GROUP BY users.id
        ORDER BY distinct_badge_count DESC
1 Like