Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
Could someone please explain me the Exists function in Qlikview and SQL.
I'm bit confused in it.
Thanks,
Ashok.
Hi,
Qlikview:
Let us assume we have tables like below
Table1:
ID
1
2
3
4
5
Table2:
ID
1
3
5
6
Suppose if you want to load the ID in Table2 which are in Table1 then use below script
Table1:
LOAD
*
FROM Table1;
Table2:
LOAD
*
FROM Table2
WHERE Exists(ID); // It will load only 1, 3,5 and filter out 6 because it is not available in Table1.
One more example:
Table1:
ID
1
1
1
1
2
3
4
5
5
If you dont want to load duplicate rows then use below script
Data:
LOAD
*
FROM Table1
WHERE NOT Exists(ID); // It will load 1 and 5 only once.
In this type of scenarios we use Exists in qlikview.
SQL Example:
The purpose of Exists() is same in both QV and SQL, the only difference is the way of using it
SELECT *
FROM Table1 AS s
WHERE EXISTS
(SELECT ID
FROM Table2 b
WHERE a.ID = b.ID);
Hope this helps you.
Regards,
Jagan.
Hi,
Qlikview:
Let us assume we have tables like below
Table1:
ID
1
2
3
4
5
Table2:
ID
1
3
5
6
Suppose if you want to load the ID in Table2 which are in Table1 then use below script
Table1:
LOAD
*
FROM Table1;
Table2:
LOAD
*
FROM Table2
WHERE Exists(ID); // It will load only 1, 3,5 and filter out 6 because it is not available in Table1.
One more example:
Table1:
ID
1
1
1
1
2
3
4
5
5
If you dont want to load duplicate rows then use below script
Data:
LOAD
*
FROM Table1
WHERE NOT Exists(ID); // It will load 1 and 5 only once.
In this type of scenarios we use Exists in qlikview.
SQL Example:
The purpose of Exists() is same in both QV and SQL, the only difference is the way of using it
SELECT *
FROM Table1 AS s
WHERE EXISTS
(SELECT ID
FROM Table2 b
WHERE a.ID = b.ID);
Hope this helps you.
Regards,
Jagan.
Thank you for your help Jagan.