Re: LISTAGG à la Oracle in PostgreSQL - Mailing list pgsql-general

From Juan Rodrigo Alejandro Burgos Mella
Subject Re: LISTAGG à la Oracle in PostgreSQL
Date
Msg-id CAHbZ42zA=VUCTWMjusbjdSemuTtKhmg-HzTGnB8n7A0ps_ebEg@mail.gmail.com
Whole thread
In response to Re: LISTAGG à la Oracle in PostgreSQL  (Pierre Forstmann <pierre.forstmann@gmail.com>)
Responses Re: LISTAGG à la Oracle in PostgreSQL
Re: LISTAGG à la Oracle in PostgreSQL
List pgsql-general
To do something similar, you would have to fork the source code and implement the declarations with the same syntax, resulting in something like Postracle.

Atte
JRBM

El mar, 10 mar 2026 a las 13:53, Pierre Forstmann (<pierre.forstmann@gmail.com>) escribió:
I agree but I just would like to know if there is way to be compatible
with Oracle syntax using aggregate features in PostgreSQL

Thanks.

Le 09/03/2026 à 23:05, Paul A Jungwirth a écrit :
> On Mon, Mar 9, 2026 at 1:21 PM Pierre Forstmann
> <pierre.forstmann@gmail.com> wrote:
>> Hello,
>>
>> I can write a LISTAGG aggregate for:
>>
>> create table emp(deptno numeric, ename text);
>>
>> SELECT deptno, LISTAGG(ename, ','::text ORDER BY ename) AS employees
>> FROM   emp GROUP BY deptno ORDER BY deptno;
>>
>> I would like to know if is possible to create an aggregate LISTAGG that
>> would work like in Oracle:
>>
>> SELECT deptno,
>>          listagg(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees
>> FROM emp
>> GROUP BY deptno
>> ORDER BY deptno;
> I don't think you need a custom aggregate here. In Postgres you can say:
>
> select deptno,
>        string_agg(ename, ',' ORDER BY ename) AS employees
> FROM emp
> GROUP BY deptno
> ORDER BY deptno;
>


pgsql-general by date:

Previous
From: Pierre Forstmann
Date:
Subject: Re: LISTAGG à la Oracle in PostgreSQL
Next
From: Isaac Morland
Date:
Subject: Re: LISTAGG à la Oracle in PostgreSQL