Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: count record from two tables with duplicate check
sim schrieb am 14.09.2005 in
<1126686039.446382.147310_at_o13g2000cwo.googlegroups.com>:
> Here's another one:
> SELECT (SELECT COUNT(*) FROM (SELECT EMP_NUM FROM A MINUS SELECT
> EMP_NUM FROM B))
> +
> (SELECT COUNT(*) FROM (SELECT EMP_NUM FROM B MINUS SELECT
> EMP_NUM FROM A))
> +
> (SELECT COUNT(*) FROM A,B WHERE A.EMP_NUM = B.EMP_NUM) CNT
> FROM DUAL
but this seems only to be the same if both tables A and B contain only
unique entries
count(distinct(union))=count(10,20,30,40)=4 count(A-B)+count(B-A)+count(A=B)=5+5+(1+5+(4x3))=28
Is this correct?
> sim
Andreas
-- wenn email, dann AndreasMosmann <bei> web <punkt> deReceived on Wed Sep 14 2005 - 03:44:55 CDT