表:sss
字段:bar,name(varchar(20))
我想写的SQL 语句是:
1。当name 字段内容为空时,统计bar 的技术数2当name 字段内容不为空时,统计bar 的技术数

解决方案 »

  1.   

    表:sss 
    字段:bar,name(varchar(20)) 
    我想写的SQL 语句是: 
    1。当name 字段内容为空时,统计bar 的记录数 2当name 字段内容不为空时,统计bar 的记录数
      

  2.   

    1。当name 字段内容为空时,统计bar 的记录数 2当name 字段内容不为空时,统计bar 的记录数
    你确定你没有写错?
    select name,count(*) from sss group by name  
      

  3.   

    你要的是这个吗?SELECT  A.CNT AS NOT_NULL_CNT,
            B.CNT AS NULL_CNT       
      FROM (SELECT  COUNT(1) CNT
              FROM  SSS
             WHERE  NAME IS NOT NULL) A,
           (SELECT  COUNT(1) CNT
              FROM  SSS
             WHERE  NAME IS NULL) B 
      

  4.   

    字段:bar ,name
    列如:
    1111111 ,小名
    2222222 ,
    3333333 ,李李我想统计:name 字段内容等于空的,表里有多少条记录?  name 字段内容不等于空的,表里有多少条记录
      

  5.   


    select sum(case when name is not null then 1 end) as 非空记录,sum(case when name is null then 1 end) as 为空记录
     from sss
      

  6.   


    select * from 
    (select count(*), 'name空' from sss  t where t.name is null)
    union
    (select count(*), 'name非空' from sss  t where t.name is not null)
      

  7.   


    --第二种方法,你自己选吧
    ---查NAME为空的记录数
    select count(*) from sss where name is null
    ---查NAME不为空的记录数
    select count(*) from sss where name is not null
      

  8.   


    (select count(*), 'name空' from sss  t where t.name is null)
    union
    (select count(*), 'name非空' from sss  t where t.name is not null)就可以了