| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL QUERY
Hi Pallv,
Should be something like this:
set serveroutput on size 1000000
set linesize 200
declare
last_value_of_oid number := null; result_string varchar2(100) := 'Hoi'; skipfirst boolean := true;begin
--
dbms_output.put_line('--'||lpad(last_value_of_oid,10)||rec.oid||lpad(result_
string,100));
if rec.oid = last_value_of_oid
then
result_string := result_string || ',' || rec.interest;
else
if skipfirst
then skipfirst := false;
else
dbms_output.put_line(lpad(last_value_of_oid,10)||lpad(result_string,100));
end if;
result_string := rec.interest;
end if;
last_value_of_oid := rec.oid;
end loop;
dbms_output.put_line(lpad(last_value_of_oid,10)||lpad(result_string,100));
end;
/
100
1,2,3
200
3,4
PL/SQL procedure successfully completed.
SQL> select * from your_table;
OID INTEREST
--------- ---------
100 1
100 2
100 3
200 3
200 4
HTH, Remco
-----Oorspronkelijk bericht-----
Van: Pallav Kalva [mailto:pallav_at_starmedia.net]
Verzonden: maandag 20 augustus 2001 15:16
Aan: Multiple recipients of list ORACLE-L
Onderwerp: SQL QUERY
>
>
> Hi List,
>
> I need an help on sql query, have a table with the following data
>
> OID INTEREST
> ---------- ----------
> 100 1
> 100 2
> 100 3
> 100 4
>
>
> I want the output to be displayed as
>
> OID INTEREST
> 100 1,2,3,4
>
> is it possible thru sql or pl/sql ?
>
> Thanks!
> Pallav
>
>
>
>
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Pallav Kalva
INET: pallav_at_starmedia.net
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: ListGuru_at_fatcity.com (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: Daemen, Remco
INET: R.Daemen_at_facent.nl
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: ListGuru_at_fatcity.com (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).
Received on Mon Aug 20 2001 - 09:28:18 CDT
![]() |
![]() |