Say I have a table with ProductID and OrderNumber. There are multiple products each with multiple orders.
What I'm trying to do is turn:
+-----------+-------------+
| ProductID | OrderNumber |
+-----------+-------------+
|         1 |           1 |
|         1 |           2 |
|         1 |           3 |
|         2 |           4 |
|         2 |           5 |
|         3 |           6 |
|         3 |           7 |
+-----------+-------------+
into:
+-----------+-------------+
| ProductID | OrderNumber |
+-----------+-------------+
|         1 |     1, 2, 3 |
|         2 |        4, 5 |
|         3 |        6, 7 |
+-----------+-------------+
It's easy enough to create a comma separated list of all the order numbers like shown here: Convert multiple rows into one with comma as separator.
What I have not been able to figure out is how to create the array from rows while still keeping the ProductID information intact.
 
    