0

Possible Duplicate:
Simulating group_concat MySQL function in MS SQL Server 2005?

The following is my employees table

EmployeeId    BossId  Name
======================================
1             5       John
2             5       Jane
3             4       Smith
4             4       Marie

And I want to get the following output

BossId      Employees
====================
5           John, Jane
4           Smith, Marie

How can we do this in one group by query?

Community
  • 1
  • 1
Hemanshu Bhojak
  • 16,454
  • 15
  • 47
  • 63
  • 4
    Use a CLR custom aggregate or `XML PATH`. This is a dupe many times over. e.g. [Simulating group_concat MySQL function in MS SQL Server 2005?](http://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-ms-sql-server-2005) – Martin Smith Feb 10 '11 at 12:36
  • 2
    Possible duplicate of so many questions. http://stackoverflow.com/questions/1339788/sql-how-to-concatenate-results or http://stackoverflow.com/questions/2828080/sql-2005-merge-concatenate-multiple-rows-to-one-column – Lamak Feb 10 '11 at 12:43

0 Answers0