Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
fredericvillemi
Specialist
Specialist

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
Partner - Champion III
Partner - Champion III

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
Partner - Champion III
Partner - Champion III

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