From: hubert depesz lubaczewski <depesz@depesz.com>
To: Pól Ua Laoínecháin <linehanp@tcd.ie>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: Arrays - selecting (and not removing) duplicates...
Date: Mon, 30 Aug 2021 15:54:46 +0200
Message-ID: <20210830135446.GB14443@depesz.com> (raw)
In-Reply-To: <CAF4RT5TLXD7rtCYBf4SoP7tzD2jDRtVU5gpQjHk+-VJ5NJC3_A@mail.gmail.com>
References: <CAF4RT5TLXD7rtCYBf4SoP7tzD2jDRtVU5gpQjHk+-VJ5NJC3_A@mail.gmail.com>
On Mon, Aug 30, 2021 at 01:47:19PM +0100, Pól Ua Laoínecháin wrote:
> I was just wondering if there is some (already written) function out
> there that will drop this functionality into my lap?
Sure, here:
#v+
create function array_dups(ANYARRAY) returns ANYARRAY as $$
select array( select i from unnest($1) i group by i having count(*) > 1 );
$$ language sql;
#v-
Best regards,
depesz
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: depesz@depesz.com, linehanp@tcd.ie
Subject: Re: Arrays - selecting (and not removing) duplicates...
In-Reply-To: <20210830135446.GB14443@depesz.com>
References: <CAF4RT5TLXD7rtCYBf4SoP7tzD2jDRtVU5gpQjHk+-VJ5NJC3_A@mail.gmail.com> <20210830135446.GB14443@depesz.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox