MySQL邮件使用情况统计方法

 

   邮件使用情况统计方法如下:

1 SELECT SUBSTRING_INDEX([column_name], '@' , -1) AS domain, COUNT(DISTINCT [column_name]) AS mail_count, COUNT([column_name]) AS mail_sum,
2 COUNT(DISTINCT [column_name])/(SELECT COUNT(DISTINCT [column_name]) FROM [table_name] WHERE [column_name] LIKE '%@%')*100 AS percent
3 FROM [table_name]
4 WHERE [column_name] LIKE '%@%'
5 GROUP BY domain
6 ORDER BY mail_count DESC LIMIT 30

  DISTINCT用来排除重复的邮箱地址,domain是邮箱域名,mail_count是统计某域名下不重复的邮箱地址数量,mail_sum是统计某域名下所有邮箱地址数量,percent是统计某域名下不重复邮箱地址数量占总的不重复邮箱地址数量的百分比。

 

posted @ 2018-10-23 16:03  PC君  阅读(433)  评论(0编辑  收藏  举报