Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL Query - JOINS

Hi,

I have 4 tables that I need the EMP Code to be linked when running a query in the script.

One          Two                         Three               Four

EMP          EMP                      EMP                EMP

DEPT         LEAVEDATE          HOURS            NAME

In my script I have simple SQL Query for each table:

SELECT * FROM One

Where DEPT <> 'A' and DEPT <> 'B'

This returns the EMP with current DEPARTMENTS

--------------------------------------------------------

SQL SELECT *

FROM Two INNER JOIN

Four ON      Two.EMP = Four.EMPREF

WHERE     (Two.LEAVEDATE IS NULL);

This returns current department and current employees

-----------------------------------------------------------

SELECT * FROM Two

WHERE LEAVEDATE IS NULL;

---------------------------------------------------------

At the moment, I use a simple SQL * from Three, but hours for all employees including leavers and old departments are returned in charts.

Do you know how I could join this table to the other tables to follow the queries?

Thanks,

Gregg

1 Solution

Accepted Solutions
Jason_Michaelides
Partner - Master II
Partner - Master II

If your first two queries are already returning all the employees you are interested in then you could use the EXISTS function in QlikView. Maybe your script could look like:

Data:

LOAD *; SQL SELECT <your query 1>;

JOIN (Data)

LOAD *; SQL SELECT <your query 2>;

JOIN (Data)

LOAD *

WHERE EXISTS (EMP)

; SQL SELECT * FROM Table3;

This way only employees that have already been loaded in the first 2 queries will be pulled by the third.

Hope this helps,

Jason

View solution in original post

1 Reply
Jason_Michaelides
Partner - Master II
Partner - Master II

If your first two queries are already returning all the employees you are interested in then you could use the EXISTS function in QlikView. Maybe your script could look like:

Data:

LOAD *; SQL SELECT <your query 1>;

JOIN (Data)

LOAD *; SQL SELECT <your query 2>;

JOIN (Data)

LOAD *

WHERE EXISTS (EMP)

; SQL SELECT * FROM Table3;

This way only employees that have already been loaded in the first 2 queries will be pulled by the third.

Hope this helps,

Jason