Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQL - Hierarchical View

433024Jan 22 2007 — edited Jan 23 2007
Hi,

SELECT lvl, TRIM(decode(lvl, 1, coa_name)) "Level 1",
TRIM(decode(lvl, 2, coa_name)) "Level 2",
TRIM(decode(lvl, 3, coa_name)) "Level 3",
TRIM(decode(lvl, 4, coa_name)) "Level 4"
FROM coa_tree
order by coa_g_code

the above statement return me data as follows:
Level
1 2 3 4
A - - -
- B
- - C
- - - D
- - - E
- - F
- - - G
- - H
- - - I
- - J
K
- L
- - M
- - - N
- - - O
P
Q
but i need output as bellow:
Level
1 2 3 4
A B C D
- - - E
- - F G
- - H I
- - J
K L M N
- - - O
- - P Q

will it possible?

(i enabled to make this output format correctly due to editor problem. kindly consider "-" as null value)

thanks
RD

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 20 2007
Added on Jan 22 2007
5 comments
6,141 views