Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

How to write a subquery with "if else" condition

Hi friends,

I have the following SQL query:

select

case when (select id from table1 where id=number) is null then 'Not Exists'

         else 'Exists'

END case,

number,name from table2;

I have created 2 QVD files with table1.qvd and table2.qvd.

I knew only this:

Load number,

        name

FROM

(qvd);

Any help is greatly appreciated.

1 Solution

Accepted Solutions
jagan
Not applicable

Re: How to write a subquery with "if else" condition

HI,

Try this

Table1:

LOAD

     id

FROM Table1.QVD;

LEFT JOIN (Table1)

LOAD

     Number as id,

     Name

FROM Table2.qvd;

Data:

LOAD

     id,

     Name,

     If(IsNull(Name), 'Not Exists', 'Exists') AS Status

RESIDENT Table1;

DROP TABLE Table1;

Hope this helps you.

Regards,

Jagan.

4 Replies
phaneendra_kunc
Not applicable

Re: How to write a subquery with "if else" condition

Try this

Table1:

Load id as number

FROM

(qvd);

Table2:

Load if( exists(number),'Exists','NotExists') as XXXX,

        name

FROM

(qvd);

jagan
Not applicable

Re: How to write a subquery with "if else" condition

HI,

Try this

Table1:

LOAD

     id

FROM Table1.QVD;

LEFT JOIN (Table1)

LOAD

     Number as id,

     Name

FROM Table2.qvd;

Data:

LOAD

     id,

     Name,

     If(IsNull(Name), 'Not Exists', 'Exists') AS Status

RESIDENT Table1;

DROP TABLE Table1;

Hope this helps you.

Regards,

Jagan.

Not applicable

Re: How to write a subquery with "if else" condition

thank you phaneendra

Not applicable

Re: How to write a subquery with "if else" condition

thanks jagan mohan. It worked.