This question already has an answer here:
I have a table with thousands of rows (unique at ID-code level) that is constructed like:
ID Code Description
1 123 A
1 789 B
2 789 B
2 123 A
2 a1b2 C
3 101 D
4 102 F
I need it to look like:
ID Description
1 A,B
2 B,A,C
3 D
4 F
Currently I am using mulitple case when conditions that look like:
max(Case when Code='123' then (description)+',' else '')+
max(Case when Code='789' then (description)+',' else '')+
etc.
Group by ID
Is there a faster way of doing this? I have been advised that using a stuff function may be viable, but honestly I can't see how a stuff function would save me any lines of code
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire