This is what i am trying to do, i want to group with same component id but can apply group by as this is the column in the view.
SELECT Business_Analyst_Team = STUFF((
SELECT DISTINCT ', ' + A.ResourceName
FROM (
Select ResourceName
,Component_ID
FROM [WFS].[Component_Resource]
join dbo.MSP_EPMResource_UserView
on dbo.MSP_EPMResource_UserView.ResourceEmailAddress = [WFS].[Component_Resource].User_Email
where [Role] ='Team Member'
and Functional_Group ='Product') A
where A.Component_ID = [WFS].[Component_Resource].Component_ID
FOR XML PATH('')), 1, 2, '')
FROM [WFS].[Component_Resource]
This is what i am getting , i wanted names with same component_id should come in same column Business_Analyst_Team ** **Component_ID
A 1
b 28439
c 28439
d 28439
e 28439
Wanted like this
**Business_Analyst_Team **
A
b,c,d,e