Reputation: 1093
This question is a variation on an older post
The conditions
If Customer_country = ‘A’
then Ship_country must = ‘A’
and Customer_number <> ‘A2’ (i.e. exclude A2)
and date is between x and y. (same for all Customer country)
The same logic goes for all Customer_country, where respective B2, C2, D2 Customer_numbers are excluded.
I am confused with using CASE…WHEN because it is expected to return a value.
But I am not returning any value. Please help with this query.
Upvotes: 0
Views: 151
Reputation: 46219
You should use where
clause instead of case when
Using ||
method to combine char like A2
or B2
... ,then you can exclude that.
SELECT *
FROM master as t1
WHERE
t1.Customer_number <> t1.Customer_Country || '2'
AND
t1.Ship_Country = t1.Customer_Country
EDIT
if the customer_number is like '981432776',you can use NOT IN
to exclude that.
SELECT *
FROM master as t1
WHERE
t1.Customer_number NOT IN ('A2','B2','C2','D2')
AND
t1.Ship_Country = t1.Customer_Country
Upvotes: 1