SELECT profile_country.name, count(DISTINCT auth_user.username) as total_users
FROM profile_country
RIGHT JOIN profile_profile ON profile_profile.country_id = profile_country.id
RIGHT JOIN auth_user ON auth_user.id = profile_profile.user_id
RIGHT JOIN users_stats_monthly ON users_stats_monthly.username = auth_user.username
WHERE users_stats_monthly.dataset='tigge-lam' and users_stats_monthly.month>=date'2013-01-01'
GROUP BY profile_country.name
HAVING count(DISTINCT auth_user.username)>=1
ORDER BY total_users DESC |