Can i join three tables in snappy data - join

I need to perform colocate join on category and subscriber tables
And i also need to perform colocate join on category and likes tables
can i denfine colocate_with option as more than one table

Define one leader region and colocate all tables with it. So by transitivity, everyone will be colocated.
e.g. table A is colocated with table B, table C is colocated with table B => Hence Table C is also colocated with table A

Related

Can I join two tables while creating a new column?

I have two tables - NETWORK and SITE. network has site_z and site_a, while SITE has a column called site_name. I would like to join them in a way that creates new fields. So that when site_z=site_name i create new column called z_site_name; and when site_a=site_name I create a new column called a_site_name.
Please advice. Thank you very much!
try
select s1.site_name site_z_name,s2.site_name site_a_name
from network n left outer join
site s1 on n.site_z=s1.site_name
left outer join site s2
on n.site_a=s2.site_name
this will give you a table that has both columns propagated with respective names.

Conditional join of two tables in Knime

I am new to Knime Analytics.
I have two tables and I need to join them not by equality, but by the difference between the values of two fields. (In sql it would look like "table1 join table2 on abs(table1.mass - table2.mass)<0.005 ") but in nodes I have found only node, that join by equality.
Are there any nodes for conditional joining tables or something like this?
The only way I can think of to do this is as follows. Use a Cross Joiner node to join all rows of each table to all rows of the second table. Now use a Java Snippet Row Filter on the joined table, with the following snippet code
return Math.abs($mass$.doubleValue() - $mass (#1)$.doubleValue()) < 0.005;
(Assuming that both incoming tables have a column called 'mass', which will become 'mass' and 'mass (#1)' after the Cross Joiner

Join tables in Hive using LIKE

I am joining tbl_A to tbl_B, on column CustomerID in tbl_A to column Output in tbl_B which contains customer ID. However, tbl_B has all other information in related rows that I do not want to lose when joining. I tried to join using like, but I lost rows that did not contain customer ID in the output column.
Here is my join query in Hive:
select a.*, b.Output from tbl_A a
left join tbl_B b
On b.Output like concat('%', a.CustomerID, '%')
However, I lose other rows from output.
You could also achieve the objective by a simple hive query like this :)
select a.*, b.Output
from tbl_A a, tbl_B b
where b.Output like concat('%', a.CustomerID, '%')
I would suggest first extract all ID's from free floating field which in your case is 'Output' column in table B into a separate table. Then join this table with ID's to Table B again to populate in each row the ID and then this second joined table which is table B with ID's to table A.
Hope this helps.

Qlikview - join two table

i need to join two table in Qlikview to get result.
Table:
I need to join this two table to get result table like this
Any idea? Can i use cross table and how?
For Table1 you can use CrossTable functionality to "rotate" the table but keeping the first column.
For example:
CrossTable(Location, Quantity)
Load
Reason,
LocA,
LocB
From
[Data.xlsx] (ooxml, embedded labels, table is Table1)
;
The result table after this will be:
Location Reason Quantity
LocA R1 5
LocA R2 4
LocA R3 5
LocA R4 3
LocB R1 2
LocB R2 2
LocB R3 3
LocB R4 5
(you can learn more about CrossTable at Qlik's help site - CrossTable)
After having Table1 in this format you can create composite key (as x3ja suggested). Composite key is basically two (or more) fields concatenated. In your case the join between the tables should be on two fields - Location and Reason.
// CrossTable the data to get it in correct format
Table1_Temp:
CrossTable(Location, Quantity)
Load
Reason,
LocA,
LocB
From
[Data.xlsx] (ooxml, embedded labels, table is Table1)
;
// Resident load to form the composite key
// based on Location and Reason fields
Table1:
Load
Location & '|' & Reason as Key,
Quantity
Resident
Table1_Temp
;
// We dont need Table1_Temp table anymore
Drop Table Table1_Temp;
//Load the second table and create the same composite key
Table2:
Load
Location & '|' & Reason as Key,
Location,
Reason,
Answer
From
[Data.xlsx] (ooxml, embedded labels, table is Table2)
;
After the reload your data model will look like:
And the data:
Notice that the values for Answer, Location, Reason are null in the bottom two rows. This is because the data in Table2 (based on your screenshots) don't contains combination for LocB and R2 and LocA and R4 but Table1 does.
If you want to keep only the combinations that are present in both tables then the approach is similar but with two differences:
Table2 should be loaded first
use keep function to exclude the non common records for being loaded in Table1
(keep at Qlik's help site - keep)
If you want to see the script in action just comment the first tab and uncomment the second one in the example qvw
There are a couple of ways you could do this.
Using association. Load Table 1 twice and concatenate, creating a composite key. So you'd end up with fields ReasonLocation and Quantity. Then load Table 2 creating the same composite key, giving you ReasonLocation, Location, Reason & Answer. Then the tables would associate on that composite key.
Using a join. Load Table1, left join in Table 1 based on Reason with an if statement like if [Location] = 'LocA' then [LocA] else [LocB]. That may need you to load it into a temp table first and do the if statement in a resident load.
You could also combine the two and join the tables in #1 based on the ReasonLocation field.
Hope that helps - sorry it's not fully worked through...

How to join this tables properly?

I have 2 tables, one is for the categories and the other is for the particulars of the corresponding categories.
I need all categories to be shown with their corresponding particulars.
I am not clear about your question and i assume you are using sql server
select t1.category,t2.particularname from categories t1 left join particulars t2 on t1.categoryid=t2.categoryid
From what you said, it seems Categories table has one-to-many relation with particulars. That means Primary Key of Categories should be refered in particulars as Foreign Key in Particulars. You can use following Query to join
SELECT * FROM categories C JOIN particulars P ON C.cat_id = P.cat_id;
And you should rename if some other columns in both tables have same name and you don't want them to be a part of JOIN.
For more example on JOIN.

Resources