0

I have a table containing many rows

I want to all rows of a column to be concatenated to single row

e.g

   columns
  -------
    a
    b
    c
    d
    e

i want to have following result

    a,b,c,d,e

2 Answers 2

2
create table test (a text);

insert into test
values ('a'), ('b'), ('c'), ('d'), ('e');

select string_agg(a, ',') from test

SQL FIDDLE EXAMPLE

Sign up to request clarification or add additional context in comments.

Comments

1
SELECT 
array_to_string(array_agg("column"),',') AS yourColumn
FROM Table1

check to see you answer demo

1 Comment

Note that on modern versions (9.0 and later, string_agg() can be used instead).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.