| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Column aggregating for text columns
> >I found this interesting question on another forum. I am going to work on
> >it, but if anyone has a solution please post it.
> >
Sorry folks, I started the thread and vanished. Sorry Joe (Celko), for not posting the DDL (I know, you hate it!! ).
OK, here is my take on solving the problem. This runs only on DB2 though.
I created a table called Test, here is the DDL for the table:
Create table:
CREATE TABLE "DB2ADMIN"."TEST" (
"ID" INTEGER NOT NULL ,
"NAME" CHAR(10) NOT NULL )
IN "USERSPACE1" ;
ID and Name together form the PK. (DDL omitted)
Later I inserted the following rows to function as the test data:
insert into test values (1, 'A') insert into test values (1, 'B') insert into test values (1, 'C') insert into test values (2, 'P') insert into test values (2, 'Q') insert into test values (3, 'X') insert into test values (3, 'Y') insert into test values (3, 'Z')
Here is the query. It uses three common table expressions, to derive the required results. The final table is the recursive query.
id Name
-- ----
1 A,B,C
2 P,Q
3 X,Y,Z
Please comment. Received on Thu May 23 2002 - 14:01:07 CDT
![]() |
![]() |