Home » SQL & PL/SQL » SQL & PL/SQL » How to put a group of columns from multiple rows into one row dynamically (10g, w2003 server)
How to put a group of columns from multiple rows into one row dynamically [message #321298] Mon, 19 May 2008 16:47 Go to next message
jbeck
Messages: 3
Registered: May 2008
Junior Member
Dear members,

I have two tables that i want to join as parent/child but i need to put the child rows into the parent row as blocks of columns.

Basically,

Parent table

id name
1 John
2 Robert
3 David

Child table

id address phone
1 xxx 674-4324433
1 yyy 678-3423422
2 zzz 473-4323423
3 ttt 876-9469839
3 uuu 345-7590275
3 nnn 948-3602134

What i would like to get is this:

id name address1 phone1 address2 phone2 address3 phone3
1 John xxx 674-4324433 yyy 678-3423422
2 Robert zzz 473-4323423
3 David ttt 876-9469839 uuu 345-7590275 nnn 948-3602134

address(n) and phone(n) has to stretch to the max number of child rows of a parent row dynamically

regards

j
Re: How to put a group of columns from multiple rows into one row dynamically [message #321300 is a reply to message #321298] Mon, 19 May 2008 17:00 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
The existing implementation is FAR SUPERIOR to the proposed change!

I won't assist with moving away from 3rd normal form.
Re: How to put a group of columns from multiple rows into one row dynamically [message #321303 is a reply to message #321300] Mon, 19 May 2008 17:09 Go to previous messageGo to next message
jbeck
Messages: 3
Registered: May 2008
Junior Member
you mean you cannot do it or my brain is too blurry to even understand you?
Re: How to put a group of columns from multiple rows into one row dynamically [message #321304 is a reply to message #321298] Mon, 19 May 2008 17:33 Go to previous messageGo to next message
jbeck
Messages: 3
Registered: May 2008
Junior Member
anyone can help me on this?
Re: How to put a group of columns from multiple rows into one row dynamically [message #321305 is a reply to message #321304] Mon, 19 May 2008 18:09 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
calm down ana, give the business what they ask for, not what you think they need...

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4144552766253
Re: How to put a group of columns from multiple rows into one row dynamically [message #321339 is a reply to message #321305] Mon, 19 May 2008 23:29 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
andrew again wrote on Tue, 20 May 2008 01:09
give the business what they ask for, not what you think they need...

Neither is 100% right, in my opinion.
Find out what the business needs. This often is sooo different from what they ask.

[Updated on: Mon, 19 May 2008 23:29]

Report message to a moderator

Re: How to put a group of columns from multiple rows into one row dynamically [message #321639 is a reply to message #321339] Tue, 20 May 2008 22:46 Go to previous messageGo to next message
harrysmall3
Messages: 109
Registered: April 2008
Location: Massachusetts
Senior Member
Unfortunately what they need usually doesnt truly surface until
post-implementation - but that keeps us all in business! Smile
Re: How to put a group of columns from multiple rows into one row dynamically [message #321650 is a reply to message #321639] Tue, 20 May 2008 23:32 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
That's why we always have to ask. Especially when the "requirements" seem odd to us.
Previous Topic: Help in Join
Next Topic: meaning
Goto Forum:
  


Current Time: Sat Dec 10 10:55:54 CST 2016

Total time taken to generate the page: 0.18458 seconds