-
aggregation in SQL query
Hi all,
I would like to aggregate the result of a hierarchical query.
Here is the query :
SELECT level,
decode(pdt_niv,5,pdt_cod,null) as niv5,
decode(pdt_niv,4,pdt_cod,null) as niv4,
decode(pdt_niv,3,pdt_cod,null) as niv3,
decode(pdt_niv,2,pdt_cod,null) as niv2,
decode(pdt_niv,1,pdt_cod,null) as niv1
from pdt
connect by pdt_cod =prior pdt_per_cod
start with pdt_niv=5
Here is the result :
LEVEL NIV5 NIV4 NIV3 NIV2 NIV1
1 F203
2 RG11
3 TPAP
4 TMAT
5 TPHR
1 F206
2 RG11
3 TPAP
4 TMAT
5 TPHR
1 P005
2 F307
3 TPAP
4 TMAT
5 TPHR
Here is the result I need :
NIV5 NIV4 NIV3 NIV2 NIV1
F203 RG11 TPAP TMAT TPHR
F206 RG11 TPAP TMAT TPHR
P005 F307 TPAP TMAT TPHR
Any idea ?
Any help would be appreciated ...
Thanks a lot in advance !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|