Custom aggregate function (concat) in SQL Server
问题 Question: I want to write a custom aggregate function that concatenates string on group by. So that I can do a SELECT SUM(FIELD1) as f1, MYCONCAT(FIELD2) as f2 FROM TABLE_XY GROUP BY FIELD1, FIELD2 All I find is SQL CRL aggregate functions, but I need SQL, without CLR. Edit:1 The query should look like this: SELECT SUM(FIELD1) as f1, MYCONCAT(FIELD2) as f2 FROM TABLE_XY GROUP BY FIELD0 Edit 2: It is true that it isn\'t possible without CLR. However, the subselect answer by astander can be