Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have two tables with very similar data and I want to combine them into one.
They have a unique key called 'data_sharing_id'
and similar fields such as dsa_exists and contract_exists will always show a value between them (one being completed the other being Null)
I want to create a combined table but my load script is not combining the non null values from the second table.
How do I get the whole table completed.
Load Script:
It turns out that the fields did not contain nulls, they contained either 'yes', 'no', or ' '.
I ended up concatenating the two tables using a select query where the contract_exsist field equalled either yes or no (and the same for the dsa_exists fields).
Full script below for those in a similar spot.
The second table has a preceding load and that preceding load only has 2 columns, not all columns needed. You need to list all in the preceding load
Hello @Markbhai
To combine the two tables based on the data_sharing_id key and fill in the null values from the second table, you can use the JOIN or MATCH keyword in your load script.
I used the IsNull functions to fill in the null values from the second table.
[data_sharing_agreement]:
LOAD
[data_sharing_id],
[dsa_exsist],
Date([dsa_expiry] ) AS [dsa_expiry]
RESIDENT
[data_sharing_agreement]
AUTOGENERATE 1
;
[contract_assessment]:
LOAD
[data_sharing_id],
[contract_exsist] AS [dsa_exsist],
Timestamp([contract_expiry] ) AS [dsa_expiry]
RESIDENT
[contract_assessment]
AUTOGENERATE 1
;
[combined_table]:
LOAD
[data_sharing_id],
[dsa_exsist] AS [dsa_exists_agreement],
If(IsNull([dsa_exists_agreement]), [contract_exists], [dsa_exists_agreement]) AS [dsa_exists],
[dsa_expiry]
RESIDENT
[data_sharing_agreement]
MATCH
[data_sharing_id]
WITH
[contract_assessment]
;
**** When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to. ****
I was having some trouble with the above, but it was very helpful. The issue I was having is that the 'AUTOGENERATE 1' and 'MATCH' were showing as Red Text in the Data Load editor and the script would not load.
I now have this:
It turns out that the fields did not contain nulls, they contained either 'yes', 'no', or ' '.
I ended up concatenating the two tables using a select query where the contract_exsist field equalled either yes or no (and the same for the dsa_exists fields).
Full script below for those in a similar spot.