Will this suit your needs?
SET SERVEROUTPUT ON FORMAT WRAPPED SIZE 1000000
DECLARE
CURSOR c1 IS
SELECT custid, software
FROM customer_software
ORDER BY custid;
id NUMBER;
sw VARCHAR2(15);
output VARCHAR2(100);
temp_id NUMBER;
temp_sw VARCHAR2(15);
BEGIN
OPEN c1;
FETCH c1 INTO id, sw;
output := id||' '||sw;
temp_id := id;
temp_sw := sw;
LOOP
FETCH c1 INTO id, sw;
EXIT WHEN c1%NOTFOUND;
IF (id = temp_id) THEN
output := output||' '||sw;
ELSE
DBMS_OUTPUT.PUT_LINE(output);
output := id||' '||sw;
END IF;
temp_id := id;
temp_sw := sw;
END LOOP;
output := id||' '||sw;
DBMS_OUTPUT.PUT_LINE(output);
CLOSE c1;
END;
/
--
Chris J. Guidry P.Eng.
ATCO Electric, Metering Services
Phone: (780) 420-4142
Fax: (780) 420-3854
Email: [EMAIL PROTECTED]
> -----Original Message-----
> From: Dave Morgan [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, January 21, 2002 02:35 PM
> To: Multiple recipients of list ORACLE-L
> Subject: Returning multiple rows as a single row
>
> Hi All,
> I know I've seen this before but I forget ...
> Given a table like
>
> Customer_Software(
> Custid Number
> Software Varchar
> )
>
> How do I return the customerid and all the software entries in a single
> row?
> Desired output is like
>
> Custid
> --------------------------------------
> 1 Excel Word StarOffice
> 2 vi tgif oracle
> ...
>
> I know it's a group by with a subquery but ....
>
>
> TIA
> Dave
> --
> Dave Morgan
> DBA, Cybersurf
> Office: 403 777 2000 ext 284
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Dave Morgan
> INET: [EMAIL PROTECTED]
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Guidry, Chris
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).