0

I am trying to use the stuff function in MS SQL to stuff certain info. Here is the example:

Number          Value 
1                 1
2                 1
3                 1
1                 2
2                 2
3                 2
1                 3
2                 3

I would like to stuff the column so that only one record will display as following:

Value             Number
1                 1,2,3
2                 1,2,3
3                 1,2

Please note that there are a like n-Numbers and n-Values.

4

1 回答 1

1

你可以用GROUP_CONCAT这个。例如:

SELECT `Value`, GROUP_CONCAT(DISTINCT `Number` ORDER BY `Number`)
FROM `yourTable`
GROUP BY `Value`
于 2013-08-08T14:18:18.740 回答