Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
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
Highlighted
MVP & Luminary
MVP & Luminary

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

View solution in original post

1 Reply
Highlighted
MVP & Luminary
MVP & Luminary

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

View solution in original post