Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Select with multiple 'WHERE' 'AND' conditions

Hello,

I am trying to select records with a number of conditions.

However, it seems like the SQL statement ignores the extra OR's. Is there another way to make this selection?

The database includes more than 30 types of smov2_action so excluding is no option.

2 Replies
Not applicable

Re: Select with multiple 'WHERE' 'AND' conditions

try below

LOAD

          smov2_part                         as [Part],

          smovqty                              as [Value],

          date(smov2_date)               as [Date];

SQL SELECT

    smov1_rec_type,

    smov2_action,

    smov2_part,

    smov2_date,

    smovqty

FROM SMOV_DATA

WHERE     smov1_co_site = 1

AND          (smov2_action = 'UPLISS'

OR            smov2_action = 'UPLREC'

OR            smov2_action = 'SALISS'

OR            smov2_action = 'WIPISS'

OR            smov2_action = 'WIPREC'

OR            smov2_action = 'WIPRRV'

OR            smov2_action = 'NILSTK');

MVP
MVP

Re: Select with multiple 'WHERE' 'AND' conditions

Hi

I would do it like this:

[StockMovements]:

LOAD

    smov2_part as [Part],

    smovqty as [Value],

    date(smov2_date) as [Date]

;

SQL SELECT

    smov2_part,

    smov2_date,

    smovqty

FROM SMOV_DATA

WHERE smov1_co_site = 1

AND smov2_action IN ('UPLISS', 'UPLREC', 'SALISS', 'WIPISS', 'WIPREC', 'WIPRRV', 'NILSTK')

;

No need to SELECT items not used in the load.

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Community Browser