I need help with my query to Combine multiple numeric values is one cell
This is the main table:
Contact_ID | Order_id | Order_group |
---|---|---|
32221 | 122223 | 55555 |
32221 | 122224 | 55555 |
32221 | 122225 | 44444 |
32221 | 122226 | 44444 |
32221 | 122227 | 44444 |
My query:
SELECT
Contact_ID,
STRING_AGG( Order_group , ', ') as 'ORDER GROUP'
FROM
Main
where Contact_ID = 32221
GROUP BY Contact_ID
what I get:
Contact_ID | ORDER GROUP |
---|---|
32221 | 55555,55555,44444,44444, no end... |
what I need is similar to this:
Contact_ID | ORDER GROUP |
---|---|
32221 | 55555,44444 |
how i can do that?