So I have the following query which does not give back the right results and I do not know why:
Sample data:
LIST1 | LIST2
APRIL | NOLA
NOLA | BEBB
NOLA | APROLS
APRA | BLIN
The query:
SELECT LIST1,
LIST2,
CASE WHEN (([LIST1] LIKE '%APR%'
OR [LIST1] LIKE '%NOLA%')
AND ([LIST2] NOT LIKE '%APR%'
AND [LIST2] NOT LIKE '%NOLA%'))
THEN 1
ELSE 0
END AS RESULTS
It gives back 1 for both rows. It should give back 0 for the first row. So I would expect the following output
LIST1 | LIST2 | RESULTS
APRIL | NOLA | 0
NOLA | BEBB | 1
NOLA | APROLS| 0
APRA | BLIN | 1
What is my mistake here? The output should be 0 for those two cases as I have clearly put in an 'AND' statement.