Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
fredericvillemi
Creator III
Creator 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
Gysbert_Wassenaar

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

View solution in original post

1 Reply
Gysbert_Wassenaar

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