SQL统计出每个字段里有多少个空值
有A表,字段有a,b,c,d,e,...,z
如何在一个语句里统计出a,b,c,d,e,...,z 的空值字段空值的条数
比如说在一个查询窗口里直接显示出 210,240,500,424,...,500 这样

解决方案 »

  1.   

    SELECT IF(A IS NULL,1,0) AS A,IF(B IS NULL ,1,0) AS B  ...
    FROM TT
      

  2.   

    ERROR:  function if(boolean, integer, integer) does not exist
    LINE 1: SELECT IF(COM_UNI_CODE IS NULL,1,0) AS COM_UNI_CODE,IF(COM_C...
                   ^
    HINT:  No function matches the given name and argument types. You might need to add explicit type casts.********** 错误 **********ERROR: function if(boolean, integer, integer) does not exist
    SQL 状态: 42883
    指导建议:No function matches the given name and argument types. You might need to add explicit type casts.
    字符:8
      

  3.   

    是MYSQL?
    SELECT SUM(CASE WHEN A IS NULL THEN 1 END)) AS A,SUM( CASE WHEN B IS NULL THEN 1 END)) AS B ...
    FROM TT
      

  4.   

     select sum(if(a<=>null,1,0)) as A,sum(if(b<=>null,1,0)) as B........
    from tt;
      

  5.   

    select sum(a is null),sum(b is null),...sum(z is null)
    from 有A表