Hi All,
Need a help.
I have data like parent-child relationship( or binary tree) like below.
code 17942 is parent having child 1863,2173 and 5678.
Again 1863 have child 301,4,5.
HIERARCHY_STRUCURE column specipfies the how to reach the element from root and CHILD_IND gives you idea about the leaf node(TRUE - Leaf node ,false- then PARENT node).
CODE | HIERARCHY_STRUCTURE | CHILD_IND |
17942 | | False |
1863 | 17942 | False |
2173 | 17942 | False |
5678 | 17942 | True |
105 | 2173,17942 | True |
301 | 1863,17942 | True |
4 | 1863,17942 | False |
5 | 1863,17942 | True |
1 | 4,1863,17942 | True |
2 | 4,1863,17942 | True |
I need to prepare SQL query where i need to find out all children elements for specified code.
i.e. if i passed codes to query from IN clause - 1863 and 5678 then expecting below 5 rows with CODE value
301,5,1,2,5678
(not 4 as its PARENT NODE).
Thanks in advance.
Rahul