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.

    评论

报告相同问题?

悬赏问题

  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别