|
|
Re: Hierarchy Tree Structure [message #627215 is a reply to message #627210] |
Sun, 09 November 2014 06:25 |
|
mughals_king
Messages: 392 Registered: January 2012 Location: pakistan
|
Senior Member |
|
|
HTREE Structure is not a problem download this example fmb and take idea from this otherwise let me know i will solve your issue according to your requirement.i don't have the exactly web-link for this but i have save some Examples follow this Hope this will help you alot.
ORDER SIBLINGS BY
The rows in a hierarchical query are returned as a tree, the children following the parent. ORDER SIBLINGS BYpreserves the hierarchy and orders the children of each parent.
SELECT
CONCAT
(
LPAD
(
' ',
LEVEL*3-3
),
ENAME
) ENAME
FROM
EMP
CONNECT BY
PRIOR EMPNO = MGR
START WITH
MGR IS NULL
ORDER SIBLINGS BY
EMP.ENAME;
ENAME
----------------
KING
BLAKE
ALLEN
JAMES
MARTIN
TURNER
WARD
CLARK
MILLER
JONES
FORD
SMITH
SCOTT
ADAMS
Clark comes after Blake and before Jones; they are under King and ordered by their name. Their children are sorted and the hierarchical appearance is preserved.
ORDER BY without SIBLINGS destroys the hierarchy:
SELECT
CONCAT
(
LPAD
(
' ',
LEVEL*3-3
),
ENAME
) ENAME
FROM
EMP
CONNECT BY
PRIOR EMPNO = MGR
START WITH
MGR IS NULL
ORDER BY
EMP.ENAME;
ENAME
--------------
ADAMS
ALLEN
BLAKE
CLARK
FORD
JAMES
JONES
KING
MARTIN
MILLER
SCOTT
SMITH
TURNER
WARD
Regards
Mughal
[Updated on: Sun, 09 November 2014 06:39] Report message to a moderator
|
|
|