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

Home -> Community -> Usenet -> c.d.o.misc -> Re: SELECTing multiple rows to a single output line

Re: SELECTing multiple rows to a single output line

From: Barbara Boehmer <baboehme_at_hotmail.com>
Date: 14 Aug 2005 20:46:06 -0700
Message-ID: <1124077566.303014.64370@g43g2000cwa.googlegroups.com>


I know you asked for a select statement without a procedure or function, so that is was I provided. However, ideally you should get your DBA to stop "unstoring" things during "maintenance", then you could use something like Tom Kyte's stragg user-defined aggregate function:

http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:2196162600402

and your code would be as simple as:

scott_at_ORA92> SELECT f.id, f.father, f.mother, f.kids,   2 stragg (c.child) AS child_names   3 FROM family f, child c
  4 WHERE f.id = c.id
  5 GROUP BY f.id, f.father, f.mother, f.kids   6 /

        ID FATHER MOTHER KIDS CHILD_NAMES

---------- ------- ------- ---------- -------------------------
         1 ALAN    ANGIE            2 ALEX,ANNETTE
         2 BILL    BETTY            3 BARBARA,BEVERLY,BOB

scott_at_ORA92>

All you need to do is copy his code, remove the line numbers, run it to create the type and function, then you can use it as demonstrated above in any similar situation. You do not need to write separate code for each such circumstance. Received on Sun Aug 14 2005 - 22:46:06 CDT

Original text of this message

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