select count(*) from table1 where a <>null

解决方案 »

  1.   

    楼上的回答不行,注意“记录为空的 ”和“记录不为空的 ”都要用SQL语句生成的
      

  2.   

    select count(*) form table1 where (a is null)为空
    select count(*) form table1 where (a is not null)不为空
      

  3.   

    select count(*) form table1 where (a is null)为空
    select count(*) form table1 where (a is not null)不为空
      

  4.   

    楼上的回答不行,我要用一条SQL语句统计,统计结果要显示在网格中
      

  5.   

    SELECT (SELECT COUNT(A) FROM table1 WHERE (A = NULL)) AS NC,(SELECT COUNT(A) FROM table1 WHERE (A <> NULL)) AS N
      

  6.   

    select count(A) from table where not (A is null)
      

  7.   

    select sum(case when 字段 is null then 1 else 0 end) as 记录为空的数量,
           sum(case when 字段 is not null then 1 else 0 end) as 记录不为空的数量
    from table
      

  8.   

    select '记录为空的' AS 统计项,
           sum(case when 字段 is null then 1 else 0 end) as 数量
    from table
    union
    select  '记录不为空的' as 统计项, 
           sum(case when 字段 is not null then 1 else 0 end) as 数量
    from table
      

  9.   

    select '记录为空的' as 统计项,
           sum(case when 字段 is null then 1 else 0 end) as 数量
    from table
    union
    select  '记录不为空的' as 统计项, 
           sum(case when 字段 is not null then 1 else 0 end) as 数量
    from table
      

  10.   

    select * from
    (select sum(1) as 为空的数量 from t1 where f1 is null)a,
    (select sum(1) as 不为空的数量 from t1 where f1 is not null)b
      

  11.   

    create table ai (a tinyint null,aa tinyint not null)
    insert into ai values(1,2)
    insert into ai values(2,2)
    insert into ai values(4,4)
    insert into ai(aa) values(2)select * from aiselect (select count(*) from ai where a is null or aa is null) as 空行数量,
    (select count(*) from ai where a is not null and aa is not null) as 不空行数量
      

  12.   

    create table ai (a tinyint null,aa tinyint not null)
    insert into ai values(1,2)
    insert into ai values(2,2)
    insert into ai values(4,4)
    insert into ai(aa) values(2)select * from ai1--
    select (select count(*) from ai where a is null or aa is null) as 空行数量,
    (select count(*) from ai where a is not null and aa is not null) as 不空行数量2---
    select '记录为空的' AS 统计项,
           sum(case when a is null or aa is null then 1 else 0 end) as 数量
    from ai
    union
    select  '记录不为空' as 统计项, 
           sum(case when a is not null and aa is not null then 1 else 0 end) as 数量
    from ai