public inbox for [email protected]
help / color / mirror / Atom feedFrom: Juan Rodrigo Alejandro Burgos Mella <[email protected]>
To: Pierre Forstmann <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: LISTAGG à la Oracle in PostgreSQL
Date: Tue, 10 Mar 2026 03:45:27 -0500
Message-ID: <CAHbZ42wBt2-C6i3520QDbURpiTooD5AWmK6s3qkFnzFPJxSZLg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Pierre
The equivalent in PostgreSQL is through:
SELECT deptno,
STRING_AGG(ename, ',' ORDER BY ename) AS employeesFROM empGROUP
BY deptnoORDER BY deptno;
Atte
JRBM
El lun, 9 mar 2026 a las 15:21, Pierre Forstmann (<
[email protected]>) escribió:
> 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 failed and IA also failed. Claude says:
>
> It is not possible to exactly replicate listagg(ename, ',') WITHIN GROUP
> (ORDER BY ename) as a custom PostgreSQL aggregate
> because PostgreSQL strictly forbids ungrouped columns as direct
> arguments to ordered-set aggregates.
>
> Do you agree ?
>
>
>
>
>
>
>
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: LISTAGG à la Oracle in PostgreSQL
In-Reply-To: <CAHbZ42wBt2-C6i3520QDbURpiTooD5AWmK6s3qkFnzFPJxSZLg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox