Hi,
People, I need to write a query in SQL Server that groups together different elements from a column using some separator like a comma.
I have a table that is more or less like this:
[tt]
++++++++++++++++++++++++++++++++++++++++++
+ department1 + John +
+ department1 + Lara +
+ department1 + Jim +
+ department2 + Cynthia +
+ department2 + Charles +
++++++++++++++++++++++++++++++++++++++++++
[/tt]
I want to write a query to get the following result:
[tt]
++++++++++++++++++++++++++++++++++++++++++
+ department1 + John, Lara, Jim +
+ department2 + Cynthia, Charles +
++++++++++++++++++++++++++++++++++++++++++
[/tt]
How can I achieve that? Thanks in advance!
People, I need to write a query in SQL Server that groups together different elements from a column using some separator like a comma.
I have a table that is more or less like this:
[tt]
++++++++++++++++++++++++++++++++++++++++++
+ department1 + John +
+ department1 + Lara +
+ department1 + Jim +
+ department2 + Cynthia +
+ department2 + Charles +
++++++++++++++++++++++++++++++++++++++++++
[/tt]
I want to write a query to get the following result:
[tt]
++++++++++++++++++++++++++++++++++++++++++
+ department1 + John, Lara, Jim +
+ department2 + Cynthia, Charles +
++++++++++++++++++++++++++++++++++++++++++
[/tt]
How can I achieve that? Thanks in advance!