Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have data like below,
ID Name
10 | Eng |
1010 | Eng |
101010 | Energy Equipment & Services |
10101010 | Oil & Gas Drilling |
10101020 | Oil & Gas Equipment & Services |
101020 | Oil |
10102010 | Integrated Oil & Gas |
10102020 | Oil & Gas Exploration & Production |
10102050 | Coal & Consumable Fuels |
15 | Materials |
1510 | Materials |
where I suppose to create hierarchy like, suppose 10 15 Should be my parent node then for 10 level 1 should be 1010 in 1010 i will have 101010 in 101010 will have next level 10101010
like, expected output would be,
ID1 Name1 ID2 Name2 ID3 Name3 ID4 Name4
10 | Eng | 1010 | Eng | 101010 | Energy Equipment & Services | 10101010 | Oil & Gas Drilling |
10 | Eng | 1010 | Eng | 101010 | Energy Equipment & Services | 10101020 | Oil & Gas Equipment & Services |
Regards,
Vijeta
to use hierarchy you need to start from a table containing your object, it's id and it's parent id.
so you need to process your table before in order to add this field.
voir exemple en PJ
Couldn't understand.
you are just creating parent and node where, my requirement is,
10->1010->101010->10101010
10->1010->101010->10101020
10->1010->101020->10102010
Googd sample, adding a 2nd hierarchy and editing the way ParentId is created (left(ID,len(ID)-2)) the result can be closer.
I have created parent Id the way I understood your requirement.
if there is other rules to generate this field feel free to do it or explain them in order to be able to provide a more suitable suggestion.
the essential is that you need to have in the same starting table, the id of the object and it's parent, other wise the hierarchy fonction won't work.
regards,
check this version
table:
load *,
left(ID,len(ID)-2) as ParentID // if len(ID)=2 then len(ID)-2=0 and parentid=id
;
LOAD * INLINE
[
ID, Name
10, Eng
1010, Eng
101010, Energy Equipment & Services
10101010, Oil & Gas Drilling
10101020, Oil & Gas Equipment & Services
101020, Oil
10102010, Integrated Oil & Gas
10102020, Oil & Gas Exploration & Production
10102050, Coal & Consumable Fuels
15, Materials
1510, Materials
];
Hierarchy(ID,ParentID,Name)
load * resident table;
drop table table;