Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
fredericvillemi
Contributor III

Filter a SQL query with the result of another query

Hi,

In Qlikview Script, is it possible to filter a SQL query based on the result of another query ?

Example :

if i load a Excel file with a column CustomerID (and 5 values), is it possible to use these values in the Where of the next SQL query of the Script ?

Thanks

1 Solution

Accepted Solutions

Re: Filter a SQL query with the result of another query

Yes that's possible. Something like:

ExcelTable:

Load concat(distinct CustomerID, ',') as IDlist

from ...myexcelfile...;

LET vIDlist = peek('IDlist');

SqlTable:

Select * from MyTable

where CustomerID in ($(vIDlist));

If your customer id's are strings you need to change the concat to create single quotes:

concat(distinct chr(39) & CustomerID & chr(39), ',') as IDlist


talk is cheap, supply exceeds demand
1 Reply

Re: Filter a SQL query with the result of another query

Yes that's possible. Something like:

ExcelTable:

Load concat(distinct CustomerID, ',') as IDlist

from ...myexcelfile...;

LET vIDlist = peek('IDlist');

SqlTable:

Select * from MyTable

where CustomerID in ($(vIDlist));

If your customer id's are strings you need to change the concat to create single quotes:

concat(distinct chr(39) & CustomerID & chr(39), ',') as IDlist


talk is cheap, supply exceeds demand
Community Browser