Max
Max

Reputation: 35

2 conditions 1 AND statement

I'm trying to exclude all data from my report that is dated before 6/1/2018 from location 170. This is what I have to work with below.

Location/Date Table

I have tried using this,

AND (Location <> 170 AND Last_Mdt < '2018-06-01'). 

I thought that if I had the parenthesis this would act as one AND statement where both conditions must be met but the report is excluding data before 2018-06-01 for all locations. Can anyone tell me what I'm doing wrong? Thanks

Upvotes: 0

Views: 39

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269953

I think you want:

AND (Location <> 170 OR Last_Mdt >= '2018-06-01')

Or, you might find this easier to follow;

AND NOT (Location = 170 AND Last_Mdt < '2018-06-01')

These are logically equivalent, assuming the columns do not take on NULL values.

Upvotes: 2

Related Questions