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: MINUS or a Nested Select

Re: MINUS or a Nested Select

From: Turkbear <john.g_at_dot.spamfree.com>
Date: Wed, 02 Feb 2005 09:59:44 -0600
Message-ID: <u1u101dltpsl28vkpnep1n18d5ubd77v53@4ax.com>


Turkbear <john.g_at_dot.spamfree.com> wrote:

>"Thiko!" <biwombi_at_hotmail.com> wrote:
>
>>Hi
>>
>>How comes this works:
>>
>>SELECT COUNT(IndexID) FROM [Table1]
>>MINUS
>>SELECT COUNT(IndexID) FROM [Table2];
>>
>>But this doesnt:
>>
>>SELECT COUNT(IndexID) FROM [Table1]
>>WHERE IndexID NOT IN (SELECT IndexID FROM [Table2]);
>>
>>I would have thought that they do the same thing??
>>Many thanks
>>
>>Thiko!
>
>Does not work how? Show the count please.
>
>But remember you are not doing subtraction of the 2 counts in your first example here, but comparison of the result of the 2
>queries. .If the Count is the same the result will be the count.
>In the second example, you are counting ONLY those NOT IN table2.
>

To help more:

If you want a count of those IndexIDs that are in Table1 but not in Table2 then use:

Select count(*) from
(select indexID from Table1 minus select indexID from Table2) ; Received on Wed Feb 02 2005 - 09:59:44 CST

Original text of this message

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