Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dturner
Starting Member
24 Posts |
Posted - 2005-12-29 : 12:10:30
|
| Hello all,I have a question that I think someone will be able to help me on.I have a table with emailaddresses and joindate. What I would like to do is count all the address for each domain.So say the domain is yahoo, I would want to count all the email addresses for that domain from my table.But the key here is to first grab all the domains and then do a count.Any good ideas.The world has more information to offer than I can hold in my head |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2005-12-29 : 12:27:01
|
| Use Group By clauseString Functions to find the Text after @ sign -- go thru BOLSome useful functions rCHARINDEX ( expression1 , expression2 [ , start_location ] ) RIGHT ( character_expression , integer_expression ) Try the following:Select RIGHT ( EmailAddress, Len(EmailAddress ) - CHARINDEX ('@' , EmailAddress )) as Domain, Count(*) as [# of emails] from MyTblGroup by RIGHT ( EmailAddress, Len(EmailAddress ) - CHARINDEX ('@' , EmailAddress )) |
 |
|
|
dturner
Starting Member
24 Posts |
Posted - 2005-12-29 : 13:23:58
|
| Thank you Srinika, that worked perfect, I was able to declare some dates so that I would not be searching all records. It worked like a charm.Again thank youThe world has more information to offer than I can hold in my head |
 |
|
|
|
|
|