Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a set of data that contains a "Parent" reference, that links back to the same table but a different record:
Customer:
LOAD
code,
name,
oid AS myCustomer,
isChildAccount,
IF(myParent=0,'',myParent) AS myParent;
SQL SELECT
code,
name,
oid,
isChildAccount,
myParent
FROM LoginSchema.Customer;
LEFT JOIN (Customer)
LOAD
getCustomer AS myCustomer,
getJCJob AS myJCJob,
myAssociatedJob,
myHousingCRMOrganisation,
getCRMOrganisation,
oid AS myHousingCustomer;
SQL SELECT
getCustomer,
getJCJob,
myAssociatedJob,
myHousingCRMOrganisation,
getCRMOrganisation,
oid
FROM LoginSchema.HousingCustomer;
I am wanting to populate everything from the parent record against the child record, but can't get my head around how to have the records loop back on themselves.
Any help would be much appreciated.
Thanks
1. Solve it directly in QlikView or Qlik Sense by using the Hierarchy load prefix:
The syntax:
Excellent articles by Qlik's own master Henric Cronström:
Unbalanced, n-level hierarchies
2. Alternatively solve it with the source database's own syntax in the SQL statement:
This is a such a common challenge so all the larger SQL database vendors have provided a special syntax to solve this. Here is the general information about the topic: Hierarchical and recursive queries in SQL - Wikipedia