user3376169
user3376169

Reputation: 429

How to concatenate varchar into a string in Redshift table

I have a table as follows:

create table #t1(a1 varchar(2))

insert into #t1 select 'AA'
insert into #t1 select 'BB'

I want final result as follows: Which aggregation function should I use.

'AA,BB'

Upvotes: 0

Views: 85

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270039

From LISTAGG Function - Amazon Redshift:

select listagg(sellerid, ', ') within group (order by sellerid) from sales
where eventid = 4337;

listagg                                                                                                                                 
----------------------------------------------------
380, 380, 1178, 1178, 1178, 2731, 8117, 12905, 32043

Upvotes: 1

Related Questions