Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Greetings everyone!
I'm stuck on something I just can't stand anymore! LoL!
I have two tables:
-------------
cust1
cust2
cust3
cust4
.........
table2:
-------------
cust1
cust2
cust8
cust5
..........
with one common field (a string field).
I must link'em together (JOIN or KEEP), and compare them to bring the records from table1 that are not referenced in table2... sounds easy, but...
...THE PROBLEM IS: the common field I'll use to link them is the same I must use to compare them, and this is causing a lot of trouble...
Could someone help me out, please???
Thanx!!!
Thiago,
it's quite difficult to understand what you are trying to accomplish, but here are some basics:
1. LEFT KEEP prefix acts as a filter - it will only load those rows that already have the same values in the identical fields. For example:
Tab1:
load Field1, ...
Tab2:
left keep (Tab1) load Field1, ...
In this example, only those rows from Tab2 will be loaded, when Field1 value already exists in Tab1.
2. the combination of LEFT KEEP and WHERE NOT EXISTS() should produce an empty set, because the two conditions are mutually exclusive.
3. If you need to compare between the two tables, you can load the same key twice, - once by the "common" name, and second time with a different name. The second instance of the key is not a key field anymore, and you can compare between the two and count them separately. For example:
Tab1:
load
Customer_Shipper,
Customer_Shipper as Customer_Shipper_Tab1,
...
Tab2:
load
Customer_Shipper,
Customer_Shipper as Customer_Shipper_Tab2,
...
Jimmy,
Can you help clarify what you are looking for by adding some more sample data and the resulting table you want?
I assume you want just one customer field that gives the data from both tables even if the don't exist in both tables?
Thanks.
Greetings Karl, thx for answering!
Here is code so far:
Customer_Shipper,
Teus
Dicionario_VS_Market:
LOAD
FROM
[..\..\Qvd\CSAV_BRASIL\MercadoECSA.qvd](qvd);LEFT
KEEP LOADDicionario_VS_Market_CROSSCHECKED:
LOAD
DISTINCTDROP
TABLESDicionario_VS_Market;
If you need any other kind of information, please let me know!
Thanx again!!
Sorry for the messed up data... here is the code:
Dicionario_VS_Market:
//Table1
LOAD
Customer_Shipper,
Teus
FROM [..\..\Qvd\CSAV_BRASIL\MercadoECSA.qvd](qvd);
//Table2
LEFT
//Bringing the merged dataLOAD DISTINCT
Customer_Shipper,
SUM(Teus) as SOMATEUS
RESIDENT Dicionario_VS_Market
GROUP BY Customer_Shipper;
Dicionario_VS_Market_CROSSCHECKED:
DROP TABLES Dicionario_VS_Market;
Thiago,
it's quite difficult to understand what you are trying to accomplish, but here are some basics:
1. LEFT KEEP prefix acts as a filter - it will only load those rows that already have the same values in the identical fields. For example:
Tab1:
load Field1, ...
Tab2:
left keep (Tab1) load Field1, ...
In this example, only those rows from Tab2 will be loaded, when Field1 value already exists in Tab1.
2. the combination of LEFT KEEP and WHERE NOT EXISTS() should produce an empty set, because the two conditions are mutually exclusive.
3. If you need to compare between the two tables, you can load the same key twice, - once by the "common" name, and second time with a different name. The second instance of the key is not a key field anymore, and you can compare between the two and count them separately. For example:
Tab1:
load
Customer_Shipper,
Customer_Shipper as Customer_Shipper_Tab1,
...
Tab2:
load
Customer_Shipper,
Customer_Shipper as Customer_Shipper_Tab2,
...
Greetings Oleg!
Sorry for the porr explanation, but you back2basics have truly helped me understand on more difference between QV language and standard SQL.
Thank you very much for sharing your wisdom!
Hi Thiago Ribeiro,
Both will give the same answer. the one & only difference between JOIN and KEEP is table view.
If u r using join means in table structure merged and show it to u one table.
if u r using keep means the answer wil b same but its shows the table separtely.
hope it help u
Hi Thiago Ribeiro,
Both will give the same answer. the one & only difference between JOIN and KEEP is table view.
If u r using join means in table structure merged and show it to u one table.
if u r using keep means the answer wil b same but its shows the table separtely.
hope it help u
Greetings Ms. Sri!
Thank you very much for your wise words.
I'll be on a QV class training next week (3-day straight), and I hope to bother you not with such seely questions anymore!
Thanx again 😃