Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: MINUS or a Nested Select
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