Oracle中,需要在查询语句中把空值(NULL)输出为0,如何处理?非常感谢

解决方案 »

  1.   

    select nvl(null,0) from dual
      

  2.   

    貌似
    select nvl(字段名,0) as 字段名,...
    from table
      

  3.   

    你不知道oracle,有一个函数叫nvl
      

  4.   

    还有一个decode函数
    如果所在列是空,就用0代替,如果不是null就是相应的字段信息select decode(cloum_name,null,0,cloum_name) from dual;还可以用‘_’来代替空
     select decode(cloum_name,null,'_',cloum_name) from dual;
      

  5.   

    nvl(col,0) -- oracle专用
    or
    decode(col,null,0,col) -- oracle专用
    or
    case when col is null then 0 else col end --所有数据库通用