Re: Arrays - selecting (and not removing) duplicates... - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject Re: Arrays - selecting (and not removing) duplicates...
Date
Msg-id 20210830135446.GB14443@depesz.com
Whole thread Raw
In response to Arrays - selecting (and not removing) duplicates...  (Pól Ua Laoínecháin <linehanp@tcd.ie>)
Responses Re: Arrays - selecting (and not removing) duplicates...
List pgsql-general
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




pgsql-general by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Pg stuck at 100% cpu, for multiple days
Next
From: Tom Lane
Date:
Subject: Re: Can we get rid of repeated queries from pg_dump?