我有一张包含电子邮件列表的表格。如何从表中检索计数值和唯一域名?
例如,
EmailTable
abc@yahoo.com
abc1@yahoo.com
abc@hotmail.com
abc23@hotmail.com
def@gmail.com
理想情况下,上述内容应返回如下内容:
count EmailDomain
2 yahoo.com
2 hotmail.com
1 gmail.com
答案 0 :(得分:3)
您可以使用基本的字符串操作和聚合来执行此操作:
select substr(e.email, instr(email, '@') + 1) as domain, count(*)
from emails e
group by substr(e.email, instr(email, '@') + 1);