| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: put all the sub-elements for a particular element next to the element on one line
you can do it with a function:
create or replace function f(id varchar2) return varchar is
result varchar2(32000) := '';
cursor curs is select ColumnB from TableA where ColumnA = id;
first boolean := true;
begin
for rec in curs loop
if first then
result := rec.ColumnB;
first := false;
else
result := result || ' ' || rec.ColumnB;
end if;
then
select ColumnA, f(ColumnA) from TableA group by ColumnA;
--
Have a nice day
Michel
Robert Moldenhauer <persia_at_persia.com> a écrit dans le message :
384DB20C.C0061C41_at_persia.com...
> If I have a table structured in the following way:
>
> TableA
>
> ColumnA | ColumnB
> Cat Ferrari
> Cat Holden
> Cat Ford
> Cat Toyota
>
> What Oracle computer code SQL or PL/SQL would twist the data so it would
>
> display in the following way:
>
> Cat Ferrari Holden Ford Toyota
>
> Essentially what I am trying to do is to put all the sub-elements for a
> particular element next to the element on one line by extending the
> following code:
>
> select ColumnA, ColumnB from TableA where ColumnA = 'Cat';
>
>
>
>
Received on Thu Dec 09 1999 - 04:26:54 CST
![]() |
![]() |