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

From Pól Ua Laoínecháin
Subject Arrays - selecting (and not removing) duplicates...
Date
Msg-id CAF4RT5TLXD7rtCYBf4SoP7tzD2jDRtVU5gpQjHk+-VJ5NJC3_A@mail.gmail.com
Whole thread Raw
Responses Re: Arrays - selecting (and not removing) duplicates...  (hubert depesz lubaczewski <depesz@depesz.com>)
List 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...



pgsql-general by date:

Previous
From: Mario Emmenlauer
Date:
Subject: lib and share are installed differently, but why?
Next
From: Avi Weinberg
Date:
Subject: get current worker processes count