Customers by Network/Domain heading SELECT DISTINCT UCASE(substring_index(A.email,'@', -1)) as domain, count(A.id) as total, sum(B.billed_amt) as sales from %%AGILE_DB_PREFIX%%account A join %%AGILE_DB_PREFIX%%invoice B on (A.id=B.account_id AND B.billing_status=1 ) A.site_id = %%DEFAULT_SITE%% AND A.email!='' AND A.email IS NOT NULL GROUP BY domain ORDER BY total DESC 0 Domain domain true true true false false Total Customers: total Total Sales: sales dol,2