我需要在两个相似的表之间执行MINUS操作,对结果行进行计数,并检查SQL语句中所有计数是否等于零。
我已经完成了以下工作,但是我不确定如何将其与零进行比较。
select count(*) from(select * from table1 MINUS SELECT * FROM table2)
答案 0 :(得分:0)
像这样吗?
SQL> with t_minus as
2 (select deptno from emp
3 minus
4 select deptno from dept
5 )
6 select case when count(*) = 0 then 'it is zero'
7 else 'it is not zero'
8 end result
9 from t_minus;
RESULT
--------------
it is zero
SQL> with t_minus as
2 (select empno from emp
3 minus
4 select deptno from dept
5 )
6 select case when count(*) = 0 then 'it is zero'
7 else 'it is not zero'
8 end result
9 from t_minus;
RESULT
--------------
it is not zero
SQL>