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

Multiple load - where statements?

I've successfully filtered out values from one table with this statement:

SQL SELECT *

FROM "Request_report".dbo."V_MSR" where app_id=3 or app_id=22 or app_id=63;

Now I need to filter out another value upon load, though:

SQL SELECT *

FROM "Request_report".dbo."V_MSR" where status_id != 0;

By themselves, these statements work fine, but I cannot figure out how to do both of them upon load. Is there something I'm missing? Is there another way to do this? I'm not looking for bookmarks, either, I'm hoping for script executed upon load if possible. If this isn't an option, I understand.

1 Solution

Accepted Solutions
Not applicable
Author

Figured it out with this code:

SQL SELECT *

FROM "Request_report".dbo."V_MSR"

where (app_id=3 or app_id=22 or app_id=63) and (status_id != 0 and status_id != 11);

Thanks for all the help everyone!

View solution in original post

6 Replies
ekech_infomotio
Partner - Creator II
Partner - Creator II

sounds you're looking for something like this?

load

     *

;

SQL SELECT *
FROM "Request_report".dbo."V_MSR" where (app_id=3 or app_id=22 or app_id=63) and status_id != 0

;

combining where-conditions in SQL is straight-forward if you know what's your AND and OR - in this case you have to use the parenthesis...

Greetings,

Edgar

Not applicable
Author

That is exactly what I needed, I wasn't using the parantheses. I'm still trying to get a hang of Qlikview syntax.

Not applicable
Author

I didn't want to make a near-duplicate post concerning this, hence the "un-corrected" response, no offense...

Now I have to filter out a status_id of "11" on load, too, so how would that go? This code doesn't work:

SQL SELECT *

FROM "Request_report".dbo."V_MSR" where (app_id=3 or app_id=22 or app_id=63) and (status_id!=11 or status_id!=0);


Once again I'm stumped with the correct syntax needed.

Miguel_Angel_Baeyens

Hi,

Do you need to load when both app_id and status_id are true? Is there a chance that you need to use OR instead of AND in the WHERE clause:

Data:

LOAD *;

SQL SELECT *
FROM "Request_report".dbo."V_MSR"

where (app_id=3 or app_id=22 or app_id=63)

or (status_id!=11 or status_id!=0);

This will retrieve all records where either the first parenthesis or the second (or both) is true.

Hope that helps.

Miguel

Not applicable
Author

To specify what I'm trying to achieve:

I have two fields (app_id & status_id). They are numeric values. I would like to load only three values from app_id (3, 22, 63) and would like to load all values but 0 and 11 in status_id. Both need to be true, not one or the other.

I've tried Miguel's code but unfortunately that didn't work. I've also tried the following:

SQL SELECT *

FROM "Request_report".dbo."V_MSR"

where (app_id=3 or app_id=22 or app_id=63) or (status_id<>11 or status_id<>0);

Is this possible?

Not applicable
Author

Figured it out with this code:

SQL SELECT *

FROM "Request_report".dbo."V_MSR"

where (app_id=3 or app_id=22 or app_id=63) and (status_id != 0 and status_id != 11);

Thanks for all the help everyone!