Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Simple SQL question

RE: Simple SQL question

From: Steven Monaghan <MonaghaS_at_mscdirect.com>
Date: Wed, 27 Sep 2000 17:08:56 -0400
Message-Id: <10632.118078@fatcity.com>


You can't in SQL to my knowledge, but it's pretty easy in PL/SQL  

declare
 cursor c1 is select distinct name from people_fruits; begin
 for rec1 in c1 loop
  declare
   cursor c2 is select fruit from people_fruits where name = rec1.name;    v1 varchar2(255);
  begin
   v1 := rec1.name||' : ';
   for rec2 in c2 loop
    v1 := v1||rec2.fruit||', ';
   end loop;
  end;
  dbms_output.put_line(v1);
  v1 := null;
 end loop;
end;
/  

You'll need to check the syntax, I did this off of the top of my head.  

Steve



Steven Monaghan
Oracle DBA
MSC Industrial Direct Co., Inc.
Melville, NY
MonaghaS_at_mscdirect.com

-----Original Message-----
From: Andrey Bronfin [mailto:bronfin_at_VisualTop.com] Sent: Wednesday, September 27, 2000 4:19 PM To: ORACLE-L_at_lists.sunysb.edu; ORACLE-L_at_fatcity.com; oracledba_at_quickdoc.co.uk
Subject: Simple SQL question

HI !  

It's too late and i can't find a simple solution for the following :  

Let's say a have a table PEOPLE_FRUITS ( NAME , FRUIT ) with the following 5 rows :
NAME FRUIT
===== =======

John       Apple 
Mike      Orange 
John      Pineapple
John      Peach
Mike      Apple
 

I want to write an SQL statement to output : John : Apple , Pineapple , Peach
Mike : Orange , Apple . Received on Wed Sep 27 2000 - 16:08:56 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US