Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

listagg distinct values - urgent

e9a4e9fb-fb72-4bc9-a96e-524067c59b26Oct 24 2014 — edited Dec 8 2014

CREATE TABLE TEST1 (COL1 STRING, COL2 NUMBER)

INSERT INTO TEST1 VALUES (A,1)

INSERT INTO TEST1 VALUES (A,2)

INSERT INTO TEST1 VALUES (B,1)

INSERT INTO TEST1 VALUES (C,3)

INSERT INTO TEST1 VALUES (A,3)

INSERT INTO TEST1 VALUES (B,5)

INSERT INTO TEST1 VALUES (C,2)

.

.

.

COMMIT;

SELECT COL1, listagg(col2, ',') within group ( order by col2)  over from test1

group by col1

OUTPUT (For a few rows)

COL1     COL2

A            1,1,2,2,2,,3,5

B 1,2,2,2,3,3,3,3,5,5,5

C 2,2,3,3,4,4,5,5

DESIRED OUTPUT

COL1      COL2

A            1.2.3.5

B            1,2,3,5

C            2,3,4,5

TEST1 TABLE HAS APPROX 10 MIL RECORDS WHICH NEED TO BE GROUPED COL1

when I try to run it on the whole table of 10 mil records, it keeps throwing an error - result of string concatenation too long.

Help needed urgent! Any advise will be deeply appreciated!!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 5 2015
Added on Oct 24 2014
6 comments
1,884 views