agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: hari.fuchs@gmail.com
To: pgsql-sql@postgresql.org
Subject: Re: Recursive merging of overlapping arrays in a column
Date: Mon, 21 Sep 2015 11:45:43 +0200
Message-ID: <87wpvkxfzs.fsf@hf.protecting.net> (raw)
References: <1442747556700-5866560.post@n5.nabble.com>
<55FEBBE0.8090902@gmail.com>
<1442764637710-5866579.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
dave <audiotecture@web.de> writes:
> Sorry, here is the post again in plain text...
>
> i have the following Table:
>
> CREATE TABLE arrays (id SERIAL, arr INT[]);
> INSERT INTO arrays (arr) VALUES (ARRAY[1,3,6,9]);
> INSERT INTO arrays (arr) VALUES (ARRAY[2,4]);
> INSERT INTO arrays (arr) VALUES (ARRAY[3,10,40]);
> INSERT INTO arrays (arr) VALUES (ARRAY[3,18,44]);
> INSERT INTO arrays (arr) VALUES (ARRAY[63,140,420]);
> INSERT INTO arrays (arr) VALUES (ARRAY[42,102,420]);
> INSERT INTO arrays (arr) VALUES (ARRAY[2,7]);
> INSERT INTO arrays (arr) VALUES (ARRAY[1,3,11]);
> INSERT INTO arrays (arr) VALUES (ARRAY[8,12,19]);
>
>
> I want to merge the arrays which have overlapping elements, so that I get
> the result which doesn't contain overlapping arrays anymore:
>
> arr
> --------------------------
> {1,3,6,9,10,11,18,40,44}
> {2,4,7}
> {8,12,19}
> {42,63,102,140,420}
The "intarray" extension (see Appendix F of the fine manual) provides an
"overlaps" operator "&&".
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (7+ messages) latest in thread
Message-ID: <87wpvkxfzs.fsf@hf.protecting.net>
Permalink: ../87wpvkxfzs.fsf@hf.protecting.net/
Also on: postgresql.org/message-id/87wpvkxfzs.fsf@hf.protecting.net
reply
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: hari.fuchs@gmail.com
Subject: Re: Recursive merging of overlapping arrays in a column
In-Reply-To: <87wpvkxfzs.fsf@hf.protecting.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox