Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Author

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');

jonathandienst
Partner - Champion III
Partner - Champion III

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