I have a table like the following:
| col_A | col_B |
|-------|-------|
| 1     | 1     |
| 1     | 2     |
| 1     | 3     |
| 2     | 1     |
| 2     | 2     |
| 2     | 3     |
| 3     | 1     |
| 3     | 2     |
I want to group and concatenate the results into an array like the following:
| col_A | col_B |
|-------|-------|
| 1,2   | 1,2,3 |
| 3     |  1,2  |
My attempt at writing a query:
SELECT col_A, array_agg(col_B ORDER BY col_B DESC) FROM table GROUP BY col_A;
However, this outputs:
| col_A | col_B   |
|-------|---------|
| 1     | {1,2,3} |
| 2     | {1,2,3} |
| 3     | {1,2}   |
 
     
    