Hi,
this query works fine
select tblProductDetails.ProductId as Id,
stuff((select ',' + CAST(PD2.SpeValue as varchar(100))
from tblProductDetails PD2 where tblProductDetails.ProductId = PD2.ProductId for xml path('')),1,1,'') Name
from tblProductDetails group by tblProductDetails.ProductId
Why this query not works
select PD.ProductId as Id,
stuff((select ',' + CAST(PD2.SpeValue as varchar(100))
from PD PD2 where PD.ProductId = PD2.ProductId for xml path('')),1,1,'') Name
from (select ProductId,SpeValue from tblProductDetails) PD group by PD.ProductId