April 3, 2008 at 2:10 am
With a table like this
NameSkill
Person ASkill A
Person ASkill B
Person ASkill C
Person BSkill A
Person BSkill C
Person CSkill B
Person CSkill C
is it possible to query, resulting in a grouping according to name, with all the skills for each person concatenated into one field (like below)
NameSkill
Person ASkill A, Skill B, Skill C
Person BSkill A, Skill C
Person CSkill B, Skill C
but without resorting to a cursor?
I've seen several articles about achieving exactly the opposite (i.e. splitting out a concatenated field into several separate rows), but I can't for the life of me think of how to tackle it this way round.
Semper in excretia, suus solum profundum variat
April 3, 2008 at 2:26 am
You could write your own aggregate function to concatenate the values, and then it becomes a simple GROUP BY query. Other than that, I can't think of any way of doing it.
John
April 3, 2008 at 2:30 am
Have a look here...http://www.sqlservercentral.com/articles/Test+Data/61572/
That should help you get what you're looking for.
April 3, 2008 at 2:52 am
SQLZ (4/3/2008)
Have a look here...http://www.sqlservercentral.com/articles/Test+Data/61572/That should help you get what you're looking for.
Sir, you're a saviour.
And Mr Moden's a bl**dy genius.
Thanks indeed.
Semper in excretia, suus solum profundum variat
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply