RT,数据库中某一有多少个空值,这样的SQL语句如何写?

解决方案 »

  1.   

    说清楚一些:是某一行有多少列的数据为空,这样的SQL怎么写呢?ORACLE数据库
      

  2.   

    select decode(字段1,null,1,0)+....+decode(字段n,null,1,0) from table;
      

  3.   

    select decode(字段1,null,1,0)+....+decode(字段n,null,1,0) 
      from table 
     where ....;
      

  4.   

    nvl2(字段,0,1)也是可以的. 
      

  5.   

    还有一种select nvl(字段1,1,0)+....+nvl(字段n,1,0) 
      from table 
     where ....;
    应该更好一点
      

  6.   

    select nvl(字段1,0,1)+....+nvl(字段n,0,1) 
      from table 
     where ....;
    在水一方太狠了。
      

  7.   


    length(col)-length(replace(col,' ',''))+length(col2)-length(replace(co2l,' ',''))......
      

  8.   

    nvl没有这种用法的.你应该也是想用nvl2的.
    SQL> select nvl(null,null,1) from dual;
     
    select nvl(null,null,1) from dual
     
    ORA-00909: invalid number of arguments
    NVL2(expr1, expr2, expr3)
    NVL2 lets you determine the value returned by a query based on whether a specified expression is null or not null. If expr1 is not null, then NVL2 returns expr2. If expr1 is null, then NVL2 returns expr3.
      

  9.   

    --他这是针对某个值里面含空值 不是整个列的值为空吧
    select nvl2(字段1,0,1)+....+nvl2(字段n,0,1) 
      

  10.   

    把列转成行,然后再抽出!=null的
      

  11.   

    谢谢各位,用了nvl2,得到了结果了