Re: Arrays - selecting (and not removing) duplicates...

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Pól Ua Laoínecháin <linehanp(at)tcd(dot)ie>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Arrays - selecting (and not removing) duplicates...
Date: 2021-08-30 13:54:46
Message-ID: 20210830135446.GB14443@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-08-30 14:11:22 Re: Can we get rid of repeated queries from pg_dump?
Previous Message hubert depesz lubaczewski 2021-08-30 13:45:10 Pg stuck at 100% cpu, for multiple days