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 -> Another Turning query on its side question

Another Turning query on its side question

From: PMG <peteg_at_garlic.com>
Date: Wed, 22 Sep 1999 23:24:49 -0700
Message-ID: <37E9C7B1.CBD1FF89@garlic.com>


I have a query which joins a parent table to a child table, 1-many. The child can have 1, 2, or 3 records for each parent id.

I am trying to turn the results so that they look like

ID_NO CHILD1 CHILD2 CHILD3 (where CHILD2 and/or CHILD3 can be null)

I am able to do the query for the cases of child count = 1 or 2, but I don't know how to extend it to the case of 3 children.

What I have so far is

select a.hs_id ID_NO, min(addr) CHILD1, decode(max(addr), min(addr), '', max(addr)) CHILD2
from table1 a, table2 b
where a.hs_id = b.hs_id
group by 1

Any suggestions? Received on Thu Sep 23 1999 - 01:24:49 CDT

Original text of this message

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