SQL - Hierarchical View
433024Jan 22 2007 — edited Jan 23 2007Hi,
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