Re: Recursive merging of overlapping arrays in a column - Mailing list pgsql-sql

From hari.fuchs@gmail.com
Subject Re: Recursive merging of overlapping arrays in a column
Date
Msg-id 87wpvkxfzs.fsf@hf.protecting.net
Whole thread Raw
In response to Recursive merging of overlapping arrays in a column  (dave <audiotecture@web.de>)
Responses Re: Recursive merging of overlapping arrays in a column
List pgsql-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 "&&".




pgsql-sql by date:

Previous
From: dave
Date:
Subject: Re: Recursive merging of overlapping arrays in a column
Next
From: dave
Date:
Subject: Re: Recursive merging of overlapping arrays in a column