I’m trying the following query:
WITH domains AS (
SELECT
SPLIT_PART(email, '@', 2) AS email_domain,
COUNT(*) AS recount
FROM users
GROUP BY email_domain
)
SELECT
DISTINCT(SPLIT_PART(email_domain, '.', 1)) AS maindomain,
recount
FROM domains
GROUP BY maindomain, recount
ORDER BY recount DESC
But I want to group the domain before the dot as one, for example I want all the “boogle’s” to count as one domain and sum the total of users with that domain (idependently of their country), but it keeps counting them as if they were different ids or domains.