这样吧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
不对啊大佬,我是要两个字段。比如 select xxx as no字段不重复的记录数量,yyy as name字段不为空的记录数量 from tb1
select (2*count(distinct t.no)-count(t.no)) as not_repeat_no,count(all t.name) from table t;
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);
select count(distinct no) , count(name) from table
select count(distinct no),sum(nvl(name,1) from table
NO不重复,两个2,name留哪个?
select count(1) from (select t.* from tab_test t where t.name is not null group by t.no having count(1) = 1)
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
写两个count的sql,然后用union链接,可以一起查出来
select count(distinct no) , count(name) from table
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值
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);
from (select t.*
from tab_test t
where t.name is not null
group by t.no
having count(1) = 1)
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值