Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> concatenate strings in a query
Sometimes I have to do reports that take a table like that (silly example):
CREATE TABLE SILLY_EXAMPLE (
KEY INTEGER,
DATA VARCHAR2(4000)
) ;
INSERT INTO SILLY_EXAMPLE VALUES (1,'AAA'); INSERT INTO SILLY_EXAMPLE VALUES (1,'BBB'); INSERT INTO SILLY_EXAMPLE VALUES (1,'CCC');
INSERT INTO SILLY_EXAMPLE VALUES (2,'XXX'); INSERT INTO SILLY_EXAMPLE VALUES (2,'YYY'); and give an output like that:
Key Data
--- --------------
1 AAA,BBB,CCC
2 XXX,YYY
I always solved using PL/SQL and a for..loop cursor with some logic
inside the loop. I'm wondering if it's possible (with Oracle 9.0.1) to
do the report with a single SQL query.
Kind regards,
-- Cris Carampa (spamto:cris119_at_operamail.com) "Welcome to the new world order Families sleepin' in their cars in the southwest No home no job no peace no rest" (Bruce Springsteen)Received on Tue Jan 27 2004 - 03:13:25 CST