From: | Thom Brown <thombrown(at)gmail(dot)com> |
---|---|
To: | Stephen Frost <sfrost(at)snowman(dot)net> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Bug with ordering aggregates? |
Date: | 2010-05-18 15:57:02 |
Message-ID: | AANLkTilhCEQDcWrSz0F0JZwHBfjo1YG5uLbtVnWaWHSu@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 18 May 2010 16:37, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
> Greetings,
>
> This doesn't seem right to me:
>
> postgres=# select
> postgres-# string_agg(column1::text order by column1 asc,',')
> postgres-# from (values (3),(4),(1),(2)) a;
> string_agg
> ------------
> 1234
> (1 row)
>
> I'm thinking we should toss a syntax error here and force the 'order
> by' to be at the end of any arguments to the aggregate.
> Alternatively, we should actually make this work like this one does:
>
> postgres=# select
> postgres-# string_agg(column1::text,',' order by column1 asc)
> postgres-# from (values (3),(4),(1),(2)) a;
> string_agg
> ------------
> 1,2,3,4
> (1 row)
>
I find that 2nd example confusing. It suggests the delimiter is being
ordered as the order by clause appears in its parameter. But I can
see why the first one is returning the wrong result. The order by
clause conflicts with the delimiter parameter as obviously the order
by clause prevents you specifying a 2nd parameter in the aggregate
function. The delimiter would either need to be the first parameter,
or the order by clause would require a way to terminate it's order by
list.
Thom
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2010-05-18 16:42:17 | Re: Bug with ordering aggregates? |
Previous Message | Tom Lane | 2010-05-18 15:46:51 | Re: Bug with ordering aggregates? |