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: 
tigra999
Contributor III
Contributor III

Retrieve specific data from db by using "AND left" and "AND"?

Hello, I am quite new to QS and my script looks like this (working fine - I get all customer numbers starting with 6, except for customer 6210)

FROM abc.dbo."purchase_order"

WHERE order_date >= '2018-01-01'

AND left(order_customer_no,1) = '6'

AND (order_customer_no) not in ('6210')

AND delete_flag = '0'

AND order_status IN ('1','2','3','4');

Now I want to also get customer numbers not starting with 6, I want to add specific customer numbers not starting with 6, for instance customer numbers 723456 and 732123.

How do I do that? I get not data when doing as below (as an example) and i have tried a number of other combinations (IN, =, sort order in script etc) without success... I get no data back. This is surely a simple fix but I cant figure it out 😞

FROM abc.dbo."purchase_order"

WHERE order_date >= '2018-01-01'

AND left (order_customer_no,1) = '6'

AND (order_customer_no) not in ('6210')

AND (order_customer_no) IN ('723456','732123')

AND delete_flag = '0'

AND order_status IN ('1','2','3','4');

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like

FROM abc.dbo."purchase_order"

WHERE order_date >= '2018-01-01'

AND

     (

      ( left (order_customer_no,1) = '6' AND order_customer_no not in ('6210') )

           OR

          order_customer_no IN ('723456','732123')

      )

AND delete_flag = '0'

AND order_status IN ('1','2','3','4');

View solution in original post

2 Replies
swuehl
MVP
MVP

Maybe like

FROM abc.dbo."purchase_order"

WHERE order_date >= '2018-01-01'

AND

     (

      ( left (order_customer_no,1) = '6' AND order_customer_no not in ('6210') )

           OR

          order_customer_no IN ('723456','732123')

      )

AND delete_flag = '0'

AND order_status IN ('1','2','3','4');

tigra999
Contributor III
Contributor III
Author

Thanx! working fine