Try thiscreate table #email ([id] int, email varchar(100), id_customers_type int)insert into #email values(1, 'xxx@yahoo.fr' ,10)insert into #email values(2, 'xx1@hotmail.com' ,20)insert into #email values(3, 'yy@gmail.com' ,2)-- the following is added for ur eg.insert into #email values(4, 'xxx@yahoo.fr' ,20)create table #customers_type ([id] int, [type] Varchar(100))insert into #customers_type values(1,'purchase_product_xx')insert into #customers_type values(2,'evalaution_product_yy')insert into #customers_type values(10,'purchase_product_zz')insert into #customers_type values(20,'purchase_product_ww')Select id_customers_type,[type], count(*) as [# of Records] from #email einner join #customers_type c on e.id_customers_type = c.[ID]group by id_customers_type,[type]drop table #emaildrop table #customers_type
Srinika