想用一条sql  搜出    no不重复的字段数量      和       name不为空的数量  

解决方案 »

  1.   

    是no字段不重复的记录数量   和    name字段不为空的记录数量   
      

  2.   

    这样吧SELECT COUNT(*) FROM TABLE_NAME T WHERE T.NO NOT IN (SELECT NO FROM TABLE_NAME  T1 GROUP BY NO HAVING COUNT(NO)>1) AND T.NAME IS NOT NULL
      

  3.   

    不对啊大佬,我是要两个字段。比如 select xxx as no字段不重复的记录数量,yyy as  name字段不为空的记录数量   from tb1
      

  4.   

    select (2*count(distinct t.no)-count(t.no)) as not_repeat_no,count(all t.name) from table t;
      

  5.   


    select *
      from table_name a
     where a.no in (select b.no
                      from table_name b
                     where b.name is not null
                     group by b.no
                    having count(1) = 1);
      

  6.   

    select count(distinct no) , count(name) from table
      

  7.   

    select count(distinct no),sum(nvl(name,1) from table
      

  8.   

    NO不重复,两个2,name留哪个?
      

  9.   

    select count(1)
      from (select t.*
              from tab_test t
             where t.name is not null
             group by t.no
            having count(1) = 1)
      

  10.   

    SELECT COUNT(*) FROM TABLE_NAME T WHERE T.NO NOT IN (SELECT NO FROM TABLE_NAME  T1 GROUP BY NO HAVING COUNT(NO)>1) AND T.NAME IS NOT NULL
      

  11.   

    写两个count的sql,然后用union链接,可以一起查出来
      

  12.   

    select count(distinct no) , count(name) from table
      

  13.   

    with a as (select 1 as no,'a' name from dual
    union all select 2,'b' from dual
    union all select 3,'c' from dual
    union all select 4,null from dual)
    select distinct count(no) as count_no,count(name) from a
    /
    DISTINCT 自动回过滤掉 null值