MySQL Query to Count Unique Domains from Email Address field

后端 未结 7 1850
执念已碎
执念已碎 2020-12-13 02:16

I\'d like to get a better idea of what domains my customers are using. I could easily do this in PHP by explodeing each address and counting the domain that way

7条回答
  •  清歌不尽
    2020-12-13 02:42

    Small tweak to Wolph's original above to shorten a bit and add nice column name and limit results in case list is long. Adjust limit to your own liking

    select substring_index(email, '@', -1) AS domain, count(*) from TABLE group by domain order by count(*) DESC limit 40;
    

提交回复
热议问题