Trying to check multiple fields for null values in order to create a master field with no null values. In the case below I am attempting to check several "city" fields until I get to a non-null value but this statement is not working as expected.
尝试检查多个字段的空值,以便创建一个没有空值的主字段。在下面的例子中,我尝试检查几个“city”字段,直到我得到一个非空值,但是这个语句并没有像预期的那样工作。
CASE
WHEN b.BillingCity IS NULL THEN b.ShippingCity
WHEN b.BillingCity IS NULL AND b.ShippingCity IS NULL THEN c.BillingCity
WHEN b.BillingCity IS NULL AND b.ShippingCity IS NULL AND c.BillingCity IS NULL THEN b.ES_APP__ESCity__c
WHEN b.BillingCity IS NULL AND b.ShippingCity IS NULL AND c.BillingCity IS NULL AND b.ES_APP__ESCity__c IS NULL THEN b.Avn_City__c
ELSE Null
END
As MasterCity
1 个解决方案
#1
6
You can just use COALESCE
:
你可以使用合并:
SELECT COALESCE(b.BillingCity,b.ShippingCity,c.BillingCity,.....)
#1
6
You can just use COALESCE
:
你可以使用合并:
SELECT COALESCE(b.BillingCity,b.ShippingCity,c.BillingCity,.....)