0
Col1 Col2
_________
A   |  1
A   |  2
A   |  3
B   |  4
B   |  5
B   |  6

and i need to obtain something like this

col1 list
________
A   | 1,2,3
B   | 4,5,6

i'm still beginner give me the most simple alternative

2
  • 1
    You have table like that, not a database (which is a bunch of tables.) Commented May 11, 2020 at 8:58
  • stackoverflow.com/questions/2560946/… Commented May 11, 2020 at 8:59

1 Answer 1

1

Try the following with array_agg

select
    col1,
    array_agg(col2)
from yourTable
group by
    col1

or with string_agg

select
    col1,
    string_agg(col2, ', ')
from yourTable
group by
    col1
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.