Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Exists function in Qlikview vs SQL

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.

View solution in original post

2 Replies
MVP & Luminary
MVP & Luminary

Re: Exists function in Qlikview vs SQL

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.

View solution in original post

Not applicable

Re: Exists function in Qlikview vs SQL

Thank you for your help Jagan.