I am trying to work some very simple logic to transform an unpivoted column into what essentially amounts to a grouped list. However, having troubles doing this efficiently.
Essentially, I have a data set that looks as follows:
CUST_ID ORDER
1 Cake
1 Bread
2 Cake
3 Cake
3 Bread
3 Croissant
4 Croissant
But would like to output it as follows:
CUST_ID ORDERS
1 Cake
1 Bread, Cake
3 Cake, Bread, Croissant
4 Croissant
I have tried subqueries (which I cannot get to work), but this seems brutal nonetheless:
SELECT CUST_ID, SELECT (ORDER FROM table GROUP BY CUST_ID)
FROM table
GROUP BY CUSTT_ID
Any ideas?