Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w03DH-001ZU2-2s for pgsql-general@arkaria.postgresql.org; Tue, 10 Mar 2026 19:57:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w03DG-005iFR-0x for pgsql-general@arkaria.postgresql.org; Tue, 10 Mar 2026 19:57:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w03DF-005iFI-2n for pgsql-general@lists.postgresql.org; Tue, 10 Mar 2026 19:57:54 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w03DE-00000001V2m-1y7j for pgsql-general@lists.postgresql.org; Tue, 10 Mar 2026 19:57:53 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-b940a00415cso742648266b.1 for ; Tue, 10 Mar 2026 12:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773172671; cv=none; d=google.com; s=arc-20240605; b=JNOlvf28mLqvL18nr1pFOpgcPr5KOiQmD7SNbD+iE+CX1P995HZ1pzItFjYm7DKTyF aGDNsfnakyy2tXqOV2LQ1O2AFZ+TtgBe7eFzdpExV5gRahSSSeYCepP4jyvrrCeB0C78 ybhn3lbFvLouTRilOIu1lkkhRJ13c/RgsOpxj7rl7uwgwIA36ZLNdbvhq+daPqSLhOIG zUUuVPQr273PNv/PkcJx8DGaaUTGLrw9On+eETLBw2t0QDaYKTmCGfsKLFHBuRTChjxT g+Pz9F0FeiPI5uOl1jNR5gO0JjzeDJvfquW0xj9o3YPcbJGX6JvncPZzdiSXZ1bGuqfi 955Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=t5qfxCzfoXQvVNo3agKTGir2p3otn1ssDs5lWMz+T7Y=; fh=7V8oQAOaOqOBt2nagq4bMOa2pftmqVwKtar1K6Szu40=; b=FgAX1Q8MrwDS3nyp9Xq9qXVS3eQEWYfdJSh4KBdgNMGuhqeGlDmVypwtWxLnTxg1wg LsbDvAol917eAnV4YJ4PQYY5AMwlvGVE4MZig8wylFOkhIPdOSh05O5WRTfXCv25p5sR nTZHM41AWrEnF7J8WFPiXkv1eiBQcI9nXhsZlhwo4NVg92FfRikcFlB0LBYKaNrAVLv9 QToQ6CvYLPc40bGnS+DAwZ0oPQ8cxZ3VZC25EiOe3qcIZFq77osTvrdXuA9fKhw/ccwM D77qQOwjlSH9o75ViLX5DU5hX5+D1mekK5nO0q8wwXmedFUedG8mttaEkK87mddlIDkJ MEmg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773172671; x=1773777471; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=t5qfxCzfoXQvVNo3agKTGir2p3otn1ssDs5lWMz+T7Y=; b=fVUoxDA5droUC0zCKSSuRXyB1TL0dcmY2r1FXD+qhHUCa9D5+Ky7eLHab6LEeOGiWc YdTn4z+ilpjbanBq9olu/Pfe5mD+u7xQz0KNfWYyhfbN60LNU4w74/T3ka2jAOl7gb/z PPk99PuHocGA1bb7oHu1ozwv1aWhz9I1TuDfLUqE18mNliekg3GKvogxa2kFg0xgF/lJ E09SrmD+k/Ju92Kx8koyzoOhWvdW4pss2x8elwIhEQOvK2CB2MZMtaeN9gubJtEhOdNI bZVMeUTFrre1ByQS/9xdIoTMJ+LA+xHaFzcFmA0zo6HjR4jtigSNl0Q5yifpk/XsAEja vbCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773172671; x=1773777471; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=t5qfxCzfoXQvVNo3agKTGir2p3otn1ssDs5lWMz+T7Y=; b=eXaTLd7plAzxhkIThdygqkGFBmr62xDICajUDTSWS6eJpyHr4gNAIRi3KzMaLrQv2z l3PH3UOhZPi9Z3yVpgyUYquSzMM5MOvS/hna4665NpxB52IA6a0hidy1Cp7jWWwPrlSV 6xIGrbeDFvXf68pMUStiWncNCXff940qy8f5dlnOd0w0ttJ7aOuOYcRdFrRzrB67OLEX XtG8504SwFGdmwsZtaB/NS7gH6lYU7yNhj3SVLW+3rUFOd4erWiwHiHCn+XmI5ZmEEOg lR8KWmuj7a5UUePon8Qtl9MsCcRT8SdNc+GOd2Tins0UK6HduEX3B6aXqXb4lya1ZTtf jH8w== X-Forwarded-Encrypted: i=1; AJvYcCU83zFLQqwAMVgDbaKpyS83uE4ApGiSpoFtrfOiBW1Ju7EweUqauTJKYNcCtx4NeGema6XOSrXIzlk9w+vl@lists.postgresql.org X-Gm-Message-State: AOJu0YzHDQyivPeZNG4G3HIw9A6afGGf3otqK3TdHAbIrLH8QPcIJAdN guEC80rNlyEIAqV1WKd2jM+vexgE6ONqzanOYuM1PBzWwTy/+EX5Wyx1kC+eWWXyjLS5R3qwLKM rsTDEh57wHU5TqZ4VEJd16bHQAzFJBVjOs0toyw== X-Gm-Gg: ATEYQzzGb9FzTqFtAMbNkc7he9DI781mzK0Qx0HmlT6+OCVBVicDs+Xm6sBfuCT5otx rfX4esOW+kHN08hYs/FL6Ecii6HGxeTtFQxy+nPdS88FL1f7E0y7AccnsneSZQY6hkiU+DZN13o gz0XjHrlO80Ljb64Fl1kfIe3QMk/i3AvP1JDV+s/tGpK2u53j/YgZ4GYI+7c49oROgUBOcD0AGv 9ZiuhnbX8gPCgEhQ+UJKwhiqp+1we4A/aGV0bVpeivTRLnGnfqzzOeq/zo11M1ViGG5qmRzTp2e amfjs2E= X-Received: by 2002:a17:907:d09:b0:b93:ff4d:8e38 with SMTP id a640c23a62f3a-b942dbde65amr971203866b.20.1773172670740; Tue, 10 Mar 2026 12:57:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Juan Rodrigo Alejandro Burgos Mella Date: Tue, 10 Mar 2026 14:57:39 -0500 X-Gm-Features: AaiRm53Czr0oUk88ubbdVFcQ7D2lmi2kgQg5Aow11jJCYFXpn3NylNlv_V3XlV0 Message-ID: Subject: =?UTF-8?Q?Re=3A_LISTAGG_=C3=A0_la_Oracle_in_PostgreSQL?= To: Pierre Forstmann Cc: Paul A Jungwirth , "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000002a3a7d064cb0ef7f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002a3a7d064cb0ef7f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=C3=B3: > 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 =C3=A0 23:05, Paul A Jungwirth a =C3=A9crit : > > On Mon, Mar 9, 2026 at 1:21=E2=80=AFPM Pierre Forstmann > > 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 tha= t > >> would work like in Oracle: > >> > >> SELECT deptno, > >> listagg(ename, ',') WITHIN GROUP (ORDER BY ename) AS employee= s > >> 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; > > > > > --0000000000002a3a7d064cb0ef7f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
To do something similar, you would have to fork the source= code and implement the declarations with the same syntax, resulting in som= ething like Postracle.

Atte
JRBM
El mar, 10 mar 2026 a las 13:53, Pierre Forstmann (<pierre.forstmann@gmail.com>= ;) escribi=C3=B3:
pi= erre.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=C2=A0 =C2=A0emp 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,
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 listagg(ename, ',') WITH= IN 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 ca= n say:
>
> select deptno,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 string_agg(ename, ',' ORDER BY enam= e) AS employees
> FROM emp
> GROUP BY deptno
> ORDER BY deptno;
>


--0000000000002a3a7d064cb0ef7f--