I have only one table
from the above table I need to find out the grandparent of child_ID.
The output must be like below
Please let me know the code either in SQL or in Qlik Sense.
Thanks in advance.
I have only one table
from the above table I need to find out the grandparent of child_ID.
The output must be like below
Please let me know the code either in SQL or in Qlik Sense.
Thanks in advance.
From you example it's hard to judge what you actually want to do, but I am assuming you are trying to create a Hierarchy.
In Qlik, what you are looking for is called Hierarchy
For your example, see below script:
Data:
LOAD * INLINE [
Parent_ID, Child_ID
a, b
b, c
c, d
d, e
];
Hierarchy (Child_ID, Parent_ID, Title, 'Parent')
LOAD
Parent_ID,
Child_ID,
Parent_ID as Title
Resident Data;
Since you do not have a title, I used Parent_ID as the title.