两个表中的行数差异 [英] Difference in number of rows in two tables

查看:58
本文介绍了两个表中的行数差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何区分两个不同表中的行数?

How can I take a difference in the counts of the number of rows in two different tables?

SQL> select count(*) from dual44;

  COUNT(*)
----------
         3

SQL> select count(*) from dual;

  COUNT(*)
----------
         1

SQL> (select count(*) from dual44)
  2  minus
  3  (select count(*) from dual)
  4  ;

  COUNT(*)
----------
         3

SQL> 

我需要 2 作为结果.这两个表不一定具有相同的架构.

I need 2 as the result. The two tables might not necessarily have the same scehma.

推荐答案

减号运算符用于删除第一个结果集的所有记录,这些记录也包含在第二个结果集中.在此处使用 -(破折号)运算符.

minus operator is used to removed all records of first result set that are also contained in second. Use - (dash) operator here.

select ((select count(*) from dual44) - (select count(*) from dual)) from dual

这篇关于两个表中的行数差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆