I need to filter the query based on the below requirement..
My query :
select * from tbltemp
Current output :
Caterogy SeqCategory DescofChange RequestId TaskCompVer
-----------------------------------------------------------------------------
BIGBEAR BIGBEAR BIGBEAR B14020002 Provide ASPM Wish List
ARCUS3PL KOJN-RE ARCUS3PL B14020002 Provide ASPM Wish List
AURORA Aurora Aurora B14020003 Provide ASPM Wish List
Desired output:
Caterogy SeqCategory DescofChange RequestId TaskCompVer
---------------------------------------------------------------------------------------
BIGBEAR,ARCUS3PL BIGBEAR,KOJN-RE BIGBEAR,ARCUS3PL B14020002 Provide ASPM Wish List
AURORA Aurora Aurora B14020003 Provide ASPM Wish List
How I need to filter the above select query in such way it generates the Actual output..
I tried using STUFF but it's throwing syntax error :
SELECT
RequestId,
STUFF((SELECT ', ' + temp2.WishItemPE
FROM tbltemp temp2
WHERE temp2.TaskCompVer = temp1.TaskCompVer
AND temp2.RequestId = temp1.RequestId
FOR XML PATH('')), 1, 1, '') AS WishItemPE
FROM
tbltemp
Error:
Incorrect syntax near 'XML'