Re: how to remove the duplicate elements from an array?

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: how to remove the duplicate elements from an array?
Дата
Msg-id 162867790807261237h6e26a745w3f018bd70d0a6684@mail.gmail.com
обсуждение исходный текст
Ответ на how to remove the duplicate elements from an array?  (Yi Zhao <yi.zhao@alibaba-inc.com>)
Ответы Re: how to remove the duplicate elements from an array?  (Yi Zhao <yi.zhao@alibaba-inc.com>)
Список pgsql-general
hello

try

create function uniq(anyarray)
returns anyarray as $$
select array(select distinct $1[i] from
generate_series(array_lower($1,1), array_upper($1,1)) g(i));
$$ language sql strict immutable;

postgres=# select uniq(array[1,2,3,1,2,3,5,2,2]);
   uniq
-----------
 {1,2,3,5}
(1 row)

regards
Pavel Stehule

2008/7/26 Yi Zhao <yi.zhao@alibaba-inc.com>:
> hi all:
> if I create an array '{44,55,66,c4,55,66,b4,55,66}',
> how to remove the duplicate elements(55, 66) from it, after remove, the
> array will be
> '{44,55,66,c4,b4}'
>
> thanks.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

В списке pgsql-general по дате отправления:

Предыдущее
От: "Julian Scarfe"
Дата:
Сообщение: Casting composite types
Следующее
От: Rich Shepard
Дата:
Сообщение: Re: Problems Restarting PostgreSQL Daemon