Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikviewwizard
Master II
Master II

Self Join on EMP

Hi All,

How to write self-join in Qlikview script?

Self Join:

select M.EMPNO as MGRNO,M.ENAME as MGRNAME,E.EMPNO,E.ENAME from EMP E LEFT OUTER JOIN EMP M on E.MGR=M.EMPNO

Output:

MGRNOMGRNAMEEMPNOENAME
7902FORD7369SMITH
7698BLAKE7499ALLEN
7698BLAKE7521WARD
7839KING7566JONES
7698BLAKE7654MARTIN
7839KING7698BLAKE
7839KING7782CLARK
7566JONES7788SCOTT
NULLNULL7839KING
7698BLAKE7844TURNER
7788SCOTT7876ADAMS
7698BLAKE7900JAMES
7566JONES7902FORD
7782CLARK7934MILLER
1 Solution

Accepted Solutions
qlikviewwizard
Master II
Master II
Author

JohnWanswered at Self join

Perhaps this:

LEFT JOIN (YourTable)
LOAD
Emp.Id as Mgr.ID
,Name as "Manager Name"
RESIDENT YourTable


Thank you JohnW

View solution in original post

2 Replies
ToniKautto
Employee
Employee

I am not sure what exactly you are trying to do. Please clarify what the input data is (the attached QVD?) and what output (your example table?) you expect after processing the data.

If your data source is SQL data base, then just load the data with your SELECT statement and you are done.

qlikviewwizard
Master II
Master II
Author

JohnWanswered at Self join

Perhaps this:

LEFT JOIN (YourTable)
LOAD
Emp.Id as Mgr.ID
,Name as "Manager Name"
RESIDENT YourTable


Thank you JohnW