Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
beaubellamy
Partner - Contributor III
Partner - Contributor III

qliksense conditional select while joining tables

I would like to recreate the SQL command below.

I am unable to use the data connection directly from Qliksense to the datebasse, we are still troubleshooting this. In the meantime, i am loading the tables as csv files into the data load editor and wanting to select the tables based on the below SQL command

select *
from workorder
    left join asset on workorder.assetnum = asset.assetnum
    left join classancestor on asset.classstructureid = classancestor.classstructureid
    left join pm on asset.assetnum = pm.assetnum
    left join locations on asset.location = locations.location
where classancestor.hierarchylevels = 0
    AND classancestor.ancestorclassid = 'TURNOUT'

Labels (1)
1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Given that your key fields are named identically in each of your source tables this should be relatively simple.

The final right join to ClassAncestor will take care of your where clause

 

[Table]:

LOAD

[field list]

FROM [Work Order];

 

LEFT JOIN (Table)

LOAD

[field list]

FROM [Asset];

 

LEFT JOIN (Table)

LOAD

[field list]

FROM [PM];

 

LEFT JOIN (Table)

LOAD

[field list]

FROM [Locations];

 

RIGHT JOIN (Table)

LOAD

[field list]

FROM [ClassAncestor]

WHERE hierarchylevels = 0
    AND ancestorclassid = 'TURNOUT';

View solution in original post

4 Replies
Claudiu_Anghelescu
Specialist
Specialist

Store the raw data from .csv into .qvd and then make the join using the .qvd tables

To help community find solutions, please don't forget to mark as correct.
beaubellamy
Partner - Contributor III
Partner - Contributor III
Author

I think i understand how to join the table in the editor (i found this https://help.qlik.com/en-US/sense/June2019/Subsystems/Hub/Content/Sense_Hub/Scripting/combine-tables...), but how do i apply the where clause?

Claudiu_Anghelescu
Specialist
Specialist

You have to create a temporary table with the LEFT JOINS and after this to import the data from the temporary table into a new table.

 

TEMP:

LOAD *

LEFT JOIN

LEFT JOIN

....;

 

FINAL_TABLE:

LOAD *

RESIDENT TABLE TEMP

WHERE ..... ;

To help community find solutions, please don't forget to mark as correct.
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Given that your key fields are named identically in each of your source tables this should be relatively simple.

The final right join to ClassAncestor will take care of your where clause

 

[Table]:

LOAD

[field list]

FROM [Work Order];

 

LEFT JOIN (Table)

LOAD

[field list]

FROM [Asset];

 

LEFT JOIN (Table)

LOAD

[field list]

FROM [PM];

 

LEFT JOIN (Table)

LOAD

[field list]

FROM [Locations];

 

RIGHT JOIN (Table)

LOAD

[field list]

FROM [ClassAncestor]

WHERE hierarchylevels = 0
    AND ancestorclassid = 'TURNOUT';