YOu would have to joins as in khtan's posted sample. Just make sure the joins are on the appropriate field. Maybe this will help, note how the joins are set up.Create Table #Desc (Desc_Key int not null, Desc_Text varchar(10) not null)Create Table #Prod (Prod_Key int not null, Prod_Name char(6) not null)Create Table #info (Prod_Key int not null, Sale_Number int not null)INSERT INTO #Desc (Desc_Key,Desc_Text)Select 1,'Desc 1' UNION ALLSelect 2,'Desc 2' UNION ALLSelect 3,'Desc 3' UNION ALLSelect 4,'Desc 4' UNION ALLSelect 5,'Desc 5' Insert Into #Prod (Prod_Key,Prod_Name)Select 1,'Prod 1' UNION ALLSelect 2,'Prod 2' UNION ALLSelect 3,'Prod 3' UNION ALLSelect 4,'Prod 4' UNION ALLSelect 5,'Prod 5'Insert Into #info (Prod_Key,Sale_Number)Select 1,1 UNION ALLSelect 1,2 UNION ALLSelect 1,3 UNION ALLSelect 1,4 UNION ALLSelect 1,5 UNION ALLSelect 2,1 UNION ALLSelect 2,2 UNION ALLSelect 2,3 UNION ALLSelect 2,4 UNION ALLSelect 2,5 Select #Prod.Prod_Key, #Desc.Desc_Text,Count(#info.Sale_Number)FROM #prod Left join #Desc on #prod.Prod_Key = #desc.Desc_Key Left Join #info on #prod.Prod_Key = #info.Prod_KeyWhere #prod.Prod_Key = 1Group by #prod.Prod_Key,Desc_TextSelect #Prod.Prod_Key, #Desc.Desc_Text,Count(#info.Sale_Number)FROM #prod Left join #Desc on #prod.Prod_Key = #desc.Desc_Key Left Join #info on #prod.Prod_Key = #info.Prod_KeyGroup by #prod.Prod_Key,Desc_TextOrder by Count(#info.sale_number) descDrop Table #prodDrop Table #descDrop Table #info
Query Results:Prod_key Desc_Text Count1 Desc 1 5
Prod_Key DEsc_Text Count1 Desc 1 52 Desc 2 53 Desc 3 04 Desc 4 05 Desc 5 0