条件
如果Customer_country ='A'
所有Customer_country都采用相同的逻辑,其中排除了相应的B2,C2,D2 Customer_numbers。
我对使用CASE ... WHEN感到困惑,因为它预计会返回一个值。 但我没有回报任何价值。请帮助解决此问题。
您应该使用where
子句而不是case when
使用||
方法组合char,如A2
或B2
...,然后你可以排除它。
SELECT *
FROM master as t1
WHERE
t1.Customer_number <> t1.Customer_Country || '2'
AND
t1.Ship_Country = t1.Customer_Country
编辑
如果customer_number类似于'981432776',您可以使用NOT IN
来排除它。
SELECT *
FROM master as t1
WHERE
t1.Customer_number NOT IN ('A2','B2','C2','D2')
AND
t1.Ship_Country = t1.Customer_Country