Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Partner - Creator
Partner - Creator

Hi Jose,

may be Helpful

[DimProductBusiness]:

LOAD *

Where Exists("ProductBusinessKey");

SQL SELECT *

FROM "DimProductBusiness";

This might Helpful......

Thanks

PM

View solution in original post

3 Replies
petter
Partner - Champion III
Partner - Champion III

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
Partner - Creator
Partner - Creator

Hi Jose,

may be Helpful

[DimProductBusiness]:

LOAD *

Where Exists("ProductBusinessKey");

SQL SELECT *

FROM "DimProductBusiness";

This might Helpful......

Thanks

PM

Anonymous
Not applicable
Author

Thank You Praveen Mallela. It worked for me