有个问题请老师帮我解决一下
select 6.66+1.11
结果为7.77 没有问题
select 6.66+1.11+isnull(a,0)
其中a为空值,结果为 7.8
select 6.66+1.11+isnull(a,0.000000001)
结果还是7.8
请问我如何得到7.77结果。
mssql ISNULL 空值转换小数位数问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- sxwws 2016-05-10 01:27关注
mysql 上查询到的isnull 函数的用法,和你写的不一样。你要不检查一下。它的含义应该是test这个表达式是不是null,如果是null,返回1,否则返回0
http://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#function_isnullISNULL(expr)
If expr is NULL, ISNULL() returns 1, otherwise it returns 0.
mysql> SELECT ISNULL(1+1);
-> 0
mysql> SELECT ISNULL(1/0);
-> 1
ISNULL() can be used instead of = to test whether a value is NULL. (Comparing a value to NULL using = always yields false.)The ISNULL() function shares some special behaviors with the IS NULL comparison operator. See the description of IS NULL.
解决 无用评论 打赏 举报