Counting the number of active profiles per country
SELECT
country(lp),
count(1)
FROM linkedin_profile lp
WHERE EXISTS (SELECT 1 FROM linkedin_profile_slug s WHERE s.linkedin_profile_id = lp.id)
AND country(lp) IN ('US', 'CA')
GROUP BY 1
ORDER BY 2 DESC;