Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i have fathers and children in the same column. Father has the cod_name's lenght smaller than children's. How can i do the relationship between them?
what i have:
cod | name |
---|---|
1234 | bla bla bla 1 |
89732738 | bla bla bla 2 |
87852030 | bla bla bla 3 |
98934796 | bla bla bla 4 |
9876 | bla bla bla 5 |
76656453 | bla bla bla 6 |
76611453 | bla bla bla 7 |
what i want:
cod | father |
---|---|
1234 | bla bla bla 1 |
9876 | bla bla bla 5 |
cod | children |
---|---|
89732738 | bla bla bla 2 |
87852030 | bla bla bla 3 |
98934796 | bla bla bla 4 |
76656453 | bla bla bla 6 |
76611453 | bla bla bla 7 |
(till ther i know how to do)
relatioship:
father | children |
---|---|
1234 | 89732738 |
1234 | 87852030 |
1234 | 98934796 |
9876 | 76656453 |
9876 | 76611453 |
Have anyone any tip?
Something like this:
T1:
LOAD *,
if(len(cod)>=len(previous(cod)),alt(peek(parent),previous(cod))) as parent INLINE [
cod, name
1234, bla bla bla 1
89732738, bla bla bla 2
87852030, bla bla bla 3
98934796, bla bla bla 4
9876, bla bla bla 5
76656453, bla bla bla 6
76611453, bla bla bla 7
];
Replace the inline load with a load statement that load your data.
Hi,
How do I know that 9876 is the father of 76611453?
Rebeca
Because of the original order. The children always come after the father, but not directly at the subsequent line.
Thats my problem to do the relatioship... 😕
Hi,
Have a look at the attachment.
Hope this is what you want.
Regards,
Kaushik Solanki
Something like this:
T1:
LOAD *,
if(len(cod)>=len(previous(cod)),alt(peek(parent),previous(cod))) as parent INLINE [
cod, name
1234, bla bla bla 1
89732738, bla bla bla 2
87852030, bla bla bla 3
98934796, bla bla bla 4
9876, bla bla bla 5
76656453, bla bla bla 6
76611453, bla bla bla 7
];
Replace the inline load with a load statement that load your data.
Hello Kaushik,
In your solution i have to describe all the relationship, and that's my problem... what i need is how to automate the relationship.
Hello Gysbert, you solved it!
Really thanks!