Thursday, June 19th, 2008 Posted in Programming | Comments Off
[singlepic=734,320,240,web20,right] This sql excerpt isolates the domain name and provides a frequency account for each domain name from a MySQL table storing customer information. Great for knowing how many users you have at each company. Using domain name can sometimes be more accurate then a freeform 'Firm name' field. It's easy to do!
select count(distinct(p.email)) as total,
substring(p.email,LOCATE('@',p.email)+ 1) as domain
FROM mycustomertable p
GROUP BY domain ORDER BY total DESC