Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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:
MGRNO | MGRNAME | EMPNO | ENAME |
7902 | FORD | 7369 | SMITH |
7698 | BLAKE | 7499 | ALLEN |
7698 | BLAKE | 7521 | WARD |
7839 | KING | 7566 | JONES |
7698 | BLAKE | 7654 | MARTIN |
7839 | KING | 7698 | BLAKE |
7839 | KING | 7782 | CLARK |
7566 | JONES | 7788 | SCOTT |
NULL | NULL | 7839 | KING |
7698 | BLAKE | 7844 | TURNER |
7788 | SCOTT | 7876 | ADAMS |
7698 | BLAKE | 7900 | JAMES |
7566 | JONES | 7902 | FORD |
7782 | CLARK | 7934 | MILLER |
Perhaps this:
LEFT JOIN (YourTable)
LOAD
Emp.Id as Mgr.ID
,Name as "Manager Name"
RESIDENT YourTable
Thank you JohnW
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.