SQL语句中的Case 应用中所碰到到的问题
字段为State 为int类型
执行SQL语句:
case isnull(state,'')
when '' then ''
when 0 then 0
end
当state 不为NULL,为0时 语句确执行 when '' then ''
导致 数据结果查询有误,
总结:在isnull与case共用时,注意字段类型问题
当改为
case isnull(state,-1)
when -1 then ''
when 0 then 0
end
总的查询结果 正确