From: | hari(dot)fuchs(at)gmail(dot)com |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Recursive merging of overlapping arrays in a column |
Date: | 2015-09-21 09:45:43 |
Message-ID: | 87wpvkxfzs.fsf@hf.protecting.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
dave <audiotecture(at)web(dot)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 "&&".
From | Date | Subject | |
---|---|---|---|
Next Message | dave | 2015-09-21 12:19:13 | Re: Recursive merging of overlapping arrays in a column |
Previous Message | dave | 2015-09-20 19:40:12 | Re: Recursive merging of overlapping arrays in a column |