Home » SQL & PL/SQL » SQL & PL/SQL » SQL Statement
SQL Statement [message #21295] Thu, 25 July 2002 01:07 Go to next message
AL
Messages: 24
Registered: October 2000
Junior Member
Well I'm new to SQL Programming and
I have a table(structure of a product) and I am tryng to create a substitute table that presents some information in columns instead of lines.
Ex : Table Structure :
Parent_part_ID line_item_no Component_part
-------------- ------------ --------------
1 1 A
1 2 B
1 3 C
1 4 D
2 1 X
2 2 Y
2 3 Z

I want to present information in this form
Parent_part_ID Cponent_part_1 ... Cponent_part_N
-------------- -------------- --------------

1 A D

Can anyone help
Thanks in advance
Re: SQL Statement [message #21302 is a reply to message #21295] Thu, 25 July 2002 06:57 Go to previous messageGo to next message
hi
Messages: 15
Registered: February 2002
Junior Member
It doesnot make sense though, because how do you know how many component rows exist for a parent part. For example till today you have like a max of component rows as 10 and tomorrow you have a 11 rows for component for each parentpart.
Re: SQL Statement [message #21307 is a reply to message #21295] Thu, 25 July 2002 09:37 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
If you do know the absolute max number of components, you can use a combination of sum and decode to translate the rows into columns. See here for an example:

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

You would want to use NULL instead of the 0 in the decode statement.
Previous Topic: Simple questions
Next Topic: Re: fetching the current and previous column value for the current record
Goto Forum:
  


Current Time: Thu Apr 25 07:49:35 CDT 2024