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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use sub-queries in qlikview scipting

How to use sub-queries in qlikview scripting?

Please explain, thanks in advance.

4 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Qlikview does not know sub-queries. If you create a select statement in the Qlikview script (or any sql statement preceded by the SQL keyword) then that statement is not processed by Qlikview, but send to the database server for execution. That means you can (in fact must) use the SQL dialect your database server understands. If your database server can handle sub-queries then you can use them in the sql statement.


talk is cheap, supply exceeds demand
anbu1984
Master III
Master III

Preceding Load

Load Fld1,Max(Fld2) Group by Fld1; //Preceding load

Load * Inline [

Fld1,Fld2

1,100

1,200

2,50

2,150 ];

its_anandrjs
Champion III
Champion III

Hi,

You can not use Sub Queries into qlikview like which is SQL, but you can use resident table or any other table load and then use Joins ( inner, left , right ) and make single table out of that tables bu conditions.

Regards

Anand

Not applicable
Author

Use QlikView functions in order to achieve it. For instance, having the following SQL Statement in a traditional applcation

SELECT department_name, employee_name, count(*) as numberOfEmployees  FROM EMPLOYEE where EMPLOYEE.ID_DEPARTMENT = DEPARTMENT.ID_DEPARTMENT AND DEPARTMENT.ID_DEPARTMENT IN (SELECT ID_DEPARTMENT FROM REGION WHERE ID_REGION="NORTH") group by department_name;

In QlikView , forget abut the latter statetement 🙂 , it is very easy, since QView in the majority of its objects aggregates automatically. For instance,  the result in a straight chart table would be:

1) Add the following as Dimensions

department_name, employee_name

and then

2) Add the following Expression and label it as numberOfEmployees

IF (ID_REGION = 'NORTH',COUNT(employee_name),0)

or

IF (MATCH(ID_REGION , 'NORTH'),COUNT(employee_name),0)