I would like to know if its possible to reorder the concatenated cells in stuff function based on another column.
As of now, I am using below query
SELECT
Id,
KPI = STUFF((SELECT DISTINCT ', ' + Name
FROM #TempTable1 b
WHERE b.Id = a.Id
FOR XML PATH('')), 1, 2, '')
but this makes an output in alphabetical order. I would like to order in based on an ID column.
Below is the result for my query
I would like to order it as QUALITY SCORE, ACCURACY. This is based on another column which is the ORDERID