nasty11pig 2016-05-09 09:23 采纳率: 0%
浏览 1534

mssql ISNULL 空值转换小数位数问题

有个问题请老师帮我解决一下
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结果。

  • 写回答

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_isnull

    ISNULL(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.

    评论

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥50 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗