Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

jigonzalez
New Contributor III

How to use WHERE EXISTS() in a SQL CLAUSE?

Hi All, I hope someone can help me

I have these tables:

LiabilitiesInformation:

    [ fields ]

SQL SELECT [ fields ]

FROM DataBase1;

PaymentsMade:

    [ fields ]

SQL SELECT [fields]

FROM DataBase1;

Customers:

    [ fields ]

SQL SELECT [ fields ]

FROM DataBase1;

But there are customers that already don't have any liability. So, I don't want them.

I decided loading LiabilitiesInformation named as a TMPLiabilitiesInformation.

Then, I created a table that be loaded with resident from TMPLiabilitiesInformation WHERE AmountOwed(a field) > 0,

and I called it LiabilitiesInformation.

and I dropped TMPLiabilitiesInformation.

Well, all is fine.

But I need load data that only exists in the new table LiabilitiesInformation

1 Solution

Accepted Solutions
praveenkumar_ma
Contributor

Re: How to use WHERE EXISTS() in a SQL CLAUSE?

Hi Jose,

may be Helpful

[DimProductBusiness]:

LOAD *

Where Exists("ProductBusinessKey");

SQL SELECT *

FROM "DimProductBusiness";

This might Helpful......

Thanks

PM

3 Replies
MVP
MVP

Re: How to use WHERE EXISTS() in a SQL CLAUSE?

You could either do it within the SELECT statement of the database or do a filter with where by putting a load in front of the SQL statement for the Customers table. The first option should be more optimal but I don't think you will notice so much difference anyway.

1) The last table could be loaded like this where CustomerID is the field that identifies the customer in the LiabilitiesInformation table and the field has the same name in the Customers table:

    LOAD

      [fields]

    WHERE

       Exists(CustomerID);

    SQL

       SELECT

          [fields]

       FROM

          <database.table>;

   

2)

     SQL

       SELECT

         [fields]

       FROM

          <database.Customer>

       WHERE

           CustomerID IN (SELECT DISTINCT CustomerID FROM <database.LiabilitiesInformation>;

praveenkumar_ma
Contributor

Re: How to use WHERE EXISTS() in a SQL CLAUSE?

Hi Jose,

may be Helpful

[DimProductBusiness]:

LOAD *

Where Exists("ProductBusinessKey");

SQL SELECT *

FROM "DimProductBusiness";

This might Helpful......

Thanks

PM

jigonzalez
New Contributor III

Re: How to use WHERE EXISTS() in a SQL CLAUSE?

Thank You Praveen Mallela. It worked for me

Community Browser