Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

minus operator not working

Amer Ramamni-OracleOct 31 2011 — edited Nov 1 2011
Hi All,


I'm having a problem using the minus operator. Here is what I'm trying to do.

The following line of code gives me a count of 869 total records.
SELECT COUNT(*) FROM PROD.case_guideline_details
The following block of code gives me a count of 805 total records.
SELECT count(*)
FROM    PROD.CASE_GUIDELINES CG,
        PROD.CASE_GUIDELINE_DETAILS X
WHERE     X.CG_ID = CG.CG_ID

UNION

SELECT count(*)
FROM PROD.CASE_GUIDELINE_DETAILS Y
      WHERE Y.gl_id IN (select gl_id from guideline_subsections
           where   glss_type = 'CRM'
           and gl_id in (select gl_id from guidelines
                         where   gl_code like '4A%' OR gl_code like '4B%'
                        ))
      AND Y.SENT_ID IS NOT NULL
what I'm trying to do is take the first query minus it from the second query to get a count of 64 records.
For some reason the MINUS operator is not working. am I using it wrong ? if I can't use the minus operator in this case what should I use ?
If I'm using the minus operator in the wrong way please direct me in the right direction.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 29 2011
Added on Oct 31 2011
9 comments
2,590 views