我正在尝试确定每个域、雅虎、谷歌、美国在线的订阅者数量......
这是我想出的,但它并没有像我想象的那样分组
select SUBSTRING(EmailAddress, PATINDEX('%@%', EmailAddress) +1, LEN(EmailAddress) -PATINDEX('%@%', EmailAddress)) As [Domain], COUNT(SUBSTRING(EmailAddress, PATINDEX('%@%', EmailAddress) +1, LEN(EmailAddress) - PATINDEX('%@%', EmailAddress))) As [Count]
from Subscribers
GROUP BY EmailAddress
结果看起来像这样
yahoo.com 1
gmail.com 1
yahoo.com 1
我想要更多这样的东西
yahoo.com 2
gmail.com 1