From: | Yi Zhao <yi(dot)zhao(at)alibaba-inc(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | pgsql-general General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: how to remove the duplicate elements from an array? |
Date: | 2008-07-26 20:36:04 |
Message-ID: | 1217104564.5215.5.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
yes, it's work.
thank u very much!
Regards
Yi
On Sat, 2008-07-26 at 21:37 +0200, Pavel Stehule wrote:
> 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(dot)zhao(at)alibaba-inc(dot)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(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-general
> >
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andrej Ricnik-Bay | 2008-07-26 20:53:09 | Re: Problems Restarting PostgreSQL Daemon |
Previous Message | Joshua D. Drake | 2008-07-26 19:59:18 | Re: php + postgresql |