From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Matthew Peter" <survivedsushi(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: pl/pgsql uniq varchar[] sort? |
Date: | 2006-04-03 15:10:22 |
Message-ID: | b42b73150604030810r3716ff33pe20ddc9169267176@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 4/3/06, Matthew Peter <survivedsushi(at)yahoo(dot)com> wrote:
>
> Hello list. I'm trying to get a unique, sorted varchar array in pl/pgsql.
> Essentially a "group by" and "order by"'d varchar[].
>
> Anyone got any ideas or point me in the right direction? Thanks.
If your data is not an array type coming off the table but you want it
to end up that way, check out array_accum at
http://www.postgresql.org/docs/8.1/static/xaggr.html. All you have to
do is order the data going into the aggregate:
select array_accum(d) from
(
select d from t order by...
)
if your data is starting off as an array type, you have a few options.
you might get the most milage out of a pl/perl procedure to sort the
type. If the arrays are small and you absolutely had to do it in
plpgsql you could copy the values into a temp table, sort it via
query, and resinsert into an array using the above technique.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Broersma Jr | 2006-04-03 15:15:28 | Re: database design questions |
Previous Message | William Leite Araújo | 2006-04-03 15:01:10 | Re: How to delete all operators |