Re: Aggregates, group, and order by

From: "Roger Hand" <RHand(at)kailea(dot)com>
To: "Michael Glaesemann" <grzm(at)myrealbox(dot)com>, "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Aggregates, group, and order by
Date: 2005-11-07 08:40:56
Message-ID: DB28E9B548192448A4E8C8A3C1B1E475611DE4@sj1-exch-01.us.corp.kailea.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, November 07, 2005 12:12 AM
Michael Glaesemann wrote:
>
> select bar_id, array_accum(foo_value)
> from ordered_foo
> group by bar_id
> order by bar_id;
> bar_id | array_accum
> --------+-----------------------------
> 1 | {delta,alpha,charlie,bravo}
> 2 | {C,B,A,D}
>
>
> The result I'd like to see is
> bar_id | array_accum
> --------+-----------------------------
> 1 | {alpha,bravo,charlie,delta}
> 2 | {A,B,C,D}

select bar_id, array_accum(foo_value)
from
(SELECT * FROM ordered_foo ORDER BY foo_pos) foo
group by bar_id
order by bar_id;

bar_id,array_accum
1,{alpha,bravo,charlie,delta}
2,{A,B,C,D}

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2005-11-07 08:47:54 Re: Aggregates, group, and order by
Previous Message Richard van den Berg 2005-11-07 08:38:24 Re: Using native win32 psql.exe using alternative cygwin