日期:2014-05-17  浏览次数:20651 次

大哥大姐们,小弟求一条查询语句,,急急急急----
select c.a,c.b from
 (select (select count(1) from 来货单) a , (select count(1) from 来货单明细) b) c

--2个表,a.来货单号=b.来货单号,我想知道这2个表中笔数是否一致,
--用orcle 怎么写一条 语句,,急===
--上面这条在orcle 会报错,意思是未指定From关键字
select

------解决方案--------------------

select (select count(*) from 来货单) - (select count(*) from 来货单明细)
from dual

------解决方案--------------------
表结构 一样的话 ,minus 下就可以了。
select * from a minus select * from b ;
------解决方案--------------------
dual 是一张伪表.是一张只有一个字段,一行记录的表


select 'aa' c1 from dual
     
     c1
-----------------
1    aa



另外 是要查询2个表的全部数量 还是查询 有对应的数量?


------解决方案--------------------
select count(*) ls3 a ,ls4 b where a.id=b.id
------解决方案--------------------
引用:

select (select count(*) from 来货单) - (select count(*) from 来货单明细)
from dual

这个可以吧。


或者  select distinct 来货单号 from 来货单 minus select distinct 来货单号 from 来货单明细
可否?