Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Another Turning query on its side question
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
![]() |
![]() |