Saturday 26 November 2011

MYSQL count email country suffix

This count gives an idea of how much of the email data is from what country.
Code:
SELECT SUBSTRING_INDEX(email, '.', -1) as Suffix, count(email) as Total
FROM members
WHERE (email != '' AND email NOT NULL)
GROUP BY Suffix
ORDER BY Total DESC
LIMIT 100;

You can remove the LIMIT so that you get a full count.



No comments: