select
case when BD.Balance = BD.NormalBalance then 'a'
when BD.OverDueBalance > 0 then 'e'
when BD.DullBalance > 0 then 'f'
when BD.BadBalance > 0 then 'g'
when BD.Balance+BD.InterestBalance1+BD.InterestBalance2 = 0 then 'o' end as 账户状态
from BUSINESS_DUEBILL BD where BusinessType in('1110161','1110162')
这条语句中的“BD.Balance+BD.InterestBalance1+BD.InterestBalance2 = 0” 是这样写吗? 但是条件符合的情况不返回o呢????应该怎么写呢????
------解决方案--------------------------------------------------------
检查字段内容是否有NULL
COALESCE(BD.Balance,0) +COALESCE(BD.InterestBalance1,0) +COALESCE(BD.InterestBalance2,0)