reverse logic

Hi there,
I am getting sales over 1 miilion when i run the query below, but i want to reverse the logic

Now  if  (SUBSTR( CAMPAIGN_CODE, 6, 1 )  = 'Q'  
      OR SUBSTR( CAMPAIGN_CODE, 8, 1 ) = 'Q'  
      OR (DTL_REV_USD > 1000000.00)))           exclude that record  



SELECT DETAIL_KEY,OPP_NUM,CAMPAIGN_CODE
,CASE WHEN (OPP_SIEBEL_SALES_STAGE_CODE in ('04','05','06','07','08')
-- AND HAS_CAMPAIGN='Y'
 AND FLOW_CODE  in ('DRS','DHS','OEM')
 AND CURR_COV_TYPE  <> 'P'
 AND PROD_PLATFORM <> 'Services'
 AND DTL_ODDS   in (10,25,50,75, 100)
 AND  (SUBSTR( CAMPAIGN_CODE, 6, 1 )  = 'Q'  
      OR SUBSTR( CAMPAIGN_CODE, 8, 1 ) = 'Q'  
      OR (DTL_REV_USD > 1000000.00)))            
THEN
    ( DTL_REV_USD )
ELSE
    ( 0 )
END AS MKT_PIPE_EXCLD_USD FROM DMART_MKT1.STG_OPP_DETAILS
WHERE OPP_NUM = '1-2YK399'
AND DETAIL_KEY ='255U-JO6VL5'
FETCH FIRST 10 ROWS ONLY
nav29Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave FordSoftware Developer / Database AdministratorCommented:

I'm not exactly sure what you're asking. But, if you're simply trying to reverse the logic of this:

(SUBSTR( CAMPAIGN_CODE, 6, 1 )  = 'Q'  
      OR SUBSTR( CAMPAIGN_CODE, 8, 1 ) = 'Q'  
      OR (DTL_REV_USD > 1000000.00)))           exclude that record  

Then, you could do this:

(SUBSTR( CAMPAIGN_CODE, 6, 1 )  <> 'Q'
      AND SUBSTR( CAMPAIGN_CODE, 8, 1 ) <> 'Q'  
      AND (DTL_REV_USD <= 1000000.00)))

HTH,
DaveSlash
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tliottaCommented:
... or simply put a NOT in front?

NOT (SUBSTR( CAMPAIGN_CODE, 6, 1 )  = 'Q'  
      OR SUBSTR( CAMPAIGN_CODE, 8, 1 ) = 'Q'  
      OR (DTL_REV_USD > 1000000.00)))           exclude that record

And note that the NOT is outside the parenthesis that combines the three tests.

NOT (A or B or C) should be equivalent to (not A and not B and not C). Changing [=] to [<>] or [>] to [<=] should be the equivalent of negating each condition.

Tom
0
momi_sabagCommented:
if you want to exclude records that has
  (SUBSTR( CAMPAIGN_CODE, 6, 1 )  = 'Q'  
      OR SUBSTR( CAMPAIGN_CODE, 8, 1 ) = 'Q'  
      OR (DTL_REV_USD > 1000000.00)))          

then you have to add it to your where clause
try
SELECT DETAIL_KEY,OPP_NUM,CAMPAIGN_CODE
,CASE WHEN (OPP_SIEBEL_SALES_STAGE_CODE in ('04','05','06','07','08')
-- AND HAS_CAMPAIGN='Y'
 AND FLOW_CODE  in ('DRS','DHS','OEM')
 AND CURR_COV_TYPE  <> 'P'
 AND PROD_PLATFORM <> 'Services'
 AND DTL_ODDS   in (10,25,50,75, 100)
THEN
    ( DTL_REV_USD )
ELSE
    ( 0 )
END AS MKT_PIPE_EXCLD_USD FROM DMART_MKT1.STG_OPP_DETAILS
WHERE OPP_NUM = '1-2YK399'
AND DETAIL_KEY ='255U-JO6VL5'

 AND  NOT ((SUBSTR( CAMPAIGN_CODE, 6, 1 )  = 'Q'  
      OR SUBSTR( CAMPAIGN_CODE, 8, 1 ) = 'Q'  
      OR (DTL_REV_USD > 1000000.00)))            )

FETCH FIRST 10 ROWS ONLY
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB2

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.