Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: count record from two tables with duplicate check

Re: count record from two tables with duplicate check

From: Andreas Mosmann <keineemails_at_gmx.de>
Date: Wed, 14 Sep 2005 10:44:55 +0200
Message-ID: <1126687495.73@user.newsoffice.de>


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

  1. 10,10,10,10,10,20,30,30,30,30
  2. 20,30,30,30,40,40,40,40,40

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> de
Received on Wed Sep 14 2005 - 03:44:55 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US