Re: [GENERAL] Aggregates, group, and order by

2005-11-08 Thread Michael Glaesemann
On Nov 7, 2005, at 17:47 , David Fetter wrote: On Mon, Nov 07, 2005 at 05:12:05PM +0900, Michael Glaesmann wrote: I'm trying to concatenate strings in variable orders using a custom aggregate. However, I'm having a difficult time figuring out the SQL I need to use to accomplish this. How ab

Re: [GENERAL] Aggregates, group, and order by

2005-11-07 Thread Tom Lane
Michael Glaesemann <[EMAIL PROTECTED]> writes: > On Nov 7, 2005, at 23:24 , Tom Lane wrote: >> Strictly speaking, you need this: >> select bar_id, array_accum(foo_value) from >> (select * from ordered_foo order by bar_id, foo_pos) as ss >> group by bar_id order by bar_id; >> ie, sort

Re: [GENERAL] Aggregates, group, and order by

2005-11-07 Thread Michael Glaesemann
On Nov 7, 2005, at 23:24 , Tom Lane wrote: Strictly speaking, you need this: select bar_id, array_accum(foo_value) from (select * from ordered_foo order by bar_id, foo_pos) as ss group by bar_id order by bar_id; ie, sort the subselect by the grouping key of the outer q

Re: [GENERAL] Aggregates, group, and order by

2005-11-07 Thread Tom Lane
Joe Conway <[EMAIL PROTECTED]> writes: > Michael Glaesemann wrote: >> I'm trying to concatenate strings in variable orders using a custom >> aggregate. > Just use a subselect -- you're looking for this, correct? > regression=# select bar_id, array_accum(foo_value) from (select * from > ordere

Re: [GENERAL] Aggregates, group, and order by

2005-11-07 Thread Roger Hand
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}

Re: [GENERAL] Aggregates, group, and order by

2005-11-07 Thread Michael Glaesemann
On Nov 7, 2005, at 17:40 , Roger Hand wrote: 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,char

Re: [GENERAL] Aggregates, group, and order by

2005-11-07 Thread Joe Conway
Michael Glaesemann wrote: I'm trying to concatenate strings in variable orders using a custom aggregate. However, I'm having a difficult time figuring out the SQL I need to use to accomplish this. Here's a test case that shows the error I'm getting. select bar_id, array_accum(foo_value) f

Re: [GENERAL] Aggregates, group, and order by

2005-11-07 Thread David Fetter
On Mon, Nov 07, 2005 at 05:12:05PM +0900, Michael Glaesmann wrote: > I'm trying to concatenate strings in variable orders using a custom > aggregate. However, I'm having a difficult time figuring out the > SQL I need to use to accomplish this. How about using the ARRAY() constructor as below? >

[GENERAL] Aggregates, group, and order by

2005-11-07 Thread Michael Glaesemann
I'm trying to concatenate strings in variable orders using a custom aggregate. However, I'm having a difficult time figuring out the SQL I need to use to accomplish this. Here's a test case that shows the error I'm getting. select version();