Re: can somebody execute this query on Oracle 11.2g and send result? - Mailing list pgsql-hackers

From Jonah H. Harris
Subject Re: can somebody execute this query on Oracle 11.2g and send result?
Date
Msg-id 36e682921001282147v5c9c4426y7a5dc24bf63340cb@mail.gmail.com
Whole thread Raw
In response to can somebody execute this query on Oracle 11.2g and send result?  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: can somebody execute this query on Oracle 11.2g and send result?
ordered aggregates using WITHIN GROUP (was Re: can somebody execute this query on Oracle 11.2g and send result?)
List pgsql-hackers
On Thu, Jan 28, 2010 at 9:10 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hello,

I can't to install Oracle, and need to know result.

CREATE TABLE foo(a varchar(10), b varchar(10));

INSERT INTO foo VALUES('aaa',',');
INSERT INTO foo VALUES('bbb',';');
INSERT INTO foo VALUES('ccc','+');

SELECT listagg(a,b) FROM foo;

That's not how listagg works.

The syntax is listagg(expression [, delimiter]) WITHIN GROUP (order by clause) [OVER partition clause]
If a delimiter is defined, it must be a constant.

Query: SELECT listagg(a, ',') WITHIN GROUP (ORDER BY a) FROM foo;
Result: aaa,bbb,ccc

Query: SELECT listagg(a, ';') WITHIN GROUP (ORDER BY a) FROM foo;
Result: aaa;bbb;ccc

Query: SELECT listagg(a, '+') WITHIN GROUP (ORDER BY a) FROM foo;
Result: aaa+bbb+ccc

--
Jonah H. Harris

pgsql-hackers by date:

Previous
From: Boszormenyi Zoltan
Date:
Subject: Re: out-of-scope cursor errors
Next
From: Scott Bailey
Date:
Subject: Re: XQuery support