Kindly help me with below query output.
This is the desired output:
Please note that the xml node <Comp1_1> is combination of Comp+GroupID+SummaryID.
Code for sample table and data:
DROP TABLE IF EXISTS #Summary
CREATE TABLE #Summary
(
Summaryid INT,
GroupID INT,
AnswerID INT,
Community VARCHAR(50),
ChildRecordID INT,
Features VARCHAR(100)
)
INSERT INTO #Summary(Summaryid, GroupID, AnswerID, Community, ChildRecordID, Features)
VALUES (1, 1, 15, 'Class A', 1, 'Good at baseball'),
(2, 1, 16, 'Class C', 1, 'Passionate Gamer'),
(2, 1, 16, 'Class C', 2, 'Nature Lover'),
(3, 2, 17, 'Class D', 1, 'Loves doing Yoga')
SELECT * FROM #Summary
Thanks in advance for looking up.
Cheers.

Comp.<Comp id="1">