Re: Recursive merging of overlapping arrays in a column
| От | hari.fuchs@gmail.com |
|---|---|
| Тема | Re: Recursive merging of overlapping arrays in a column |
| Дата | |
| Msg-id | 87wpvkxfzs.fsf@hf.protecting.net обсуждение исходный текст |
| Ответ на | Recursive merging of overlapping arrays in a column (dave <audiotecture@web.de>) |
| Ответы |
Re: Recursive merging of overlapping arrays in a column
|
| Список | 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 по дате отправления: