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

From: Pól Ua Laoínecháin <linehanp(at)tcd(dot)ie>
To: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Arrays - selecting (and not removing) duplicates...
Date: 2021-08-30 12:47:19
Message-ID: CAF4RT5TLXD7rtCYBf4SoP7tzD2jDRtVU5gpQjHk+-VJ5NJC3_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

Suppose I have two arrays (TEXT, INT - not important - prefer INT) as follows:

x = {1, 4, 5, 6, 6, 7, 8, 9, 9, 9, 9, 10, 12, 12}

I would like a result of:

y = {6, 9, 12}

I'm aware of the UNNEST function and that I can convert the array into
rows and do a COUNT(blah) HAVING COUNT(blah) > 1 and then ARRAY_AGG
back.

I was just wondering if there is some (already written) function out
there that will drop this functionality into my lap?

TIA and Rgs,

Pól...

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Avi Weinberg 2021-08-30 13:00:08 get current worker processes count
Previous Message Mario Emmenlauer 2021-08-30 10:53:54 lib and share are installed differently, but why?