Why won't combined AND statement work

I want to exclude records based on two criteria's: status = 'M' and the status reason = 52.
The table contains records with status = 'M' and status reason other than 52.
Also the table contains records with status other than 'M' and status reason = 52 and I want to include those records.
I first tried using the statement below reasoning that placing the two criteria's in parenthesis would combine them and only exclude records with M 52
Where (nvl(Status_CD,'A') <> 'M' AND nvl(STATUS_RESN_CD,0) <> 52 )
However the query removed all records with Status_CD 'M' and all records with Status_Resn_CD 52. 
Using the Where Not statement worked.
Where Not (External_Status_CD = 'M' and EXT_STAT_RESN_CD = 52 ) 
I’m curious why the first statement didn’t work?
Can anyone explain why the first query didn't combine the 2 statements but a Where Not did?
Thank you - Mark

HI, Mark,
markjames9 wrote:
I want to exclude records based on two criteria's: status = 'M' and the status reason = 52.
The table contains records with status = 'M' and status reason other than 52.
Also the table contains records with status other than 'M' and status reason = 52 and I want to include those records.
I first tried using the statement below reasoning that placing the two criteria's in parenthesis would combine them and only exclude records with M 52
Where (nvl(Status_CD,'A') <> 'M' AND nvl(STATUS_RESN_CD,0) <> 52 )
However the query removed all records with Status_CD 'M' and all records with Status_Resn_CD 52.
Using the Where Not statement worked.
Where Not (External_Status_CD = 'M' and EXT_STAT_RESN_CD = 52 ) 
I’m curious why the first statement didn’t work?
Can anyone explain why the first query didn't combine the 2 statements but a Where Not did?
Thank you - Mark
Another way of looking at it:
The condition (x AND y) will be TRUE when both x AND y are TRUE.
If
sub-condition x is    nvl (Status_CD, 'A') <> 'M'   and
sub-condition y is  nvl (STATUS_RESN_CD, 0) <> 52
then any row with status_cd = 'M' fails sub-condition x, therefore the compound condition is FALSE, regardless of status_resn_cd.
Likewise, and row with status_resn_cd=52 fails sub-condition y, so the compound condition is FALSE regardless of status_cd.
You used status_cd and status_resn_cd in one example; but
EXTERNAL_status_cd and EXT_stat_resn_cd in the other.  That's quite confusing.  Also, you'll confuse everyone (including yourself) if status is abbreviated as stat in some places but not in others.  Either way is okay, but be consistent.  The same goes for abbreviating external as ext; pick one or the other, and use the same word in all places.
Don't forget to check for NULLs.  If  external_status_cd and ext_stat_resn_cd can be NULL, you should say
Where Not (    NVL (External_Status_CD, 'A') = 'M'
          and  NVL (EXT_STAT_RESN_CD,    0)  = 52
depending on your requirements.

Similar Messages

  • Why won't podcasts and store work after I upgraded to itunes 11.0.1.12

    I upgraded itunes 11.0.1.12 and now my podcasts won't load and I can't get to the store.  My internet is working and connected because I can get on other websites. 

    Looks like it was an external drive problem.  Once I saw vids were skipping other video players, and file transfers from The WD drive paused and started like the videos played told me it was a hardware problem. No more Western Digital drives for me.

  • Why won't this MERGE statement work?

    I am testing out a MERGE statement, which contains a subquery that will return no rows...on this condition, it should insert a record; however I get 0 records merged. Why is this?
    Ultimately, the hard-coded values will actually be passed in as parameters. If those a record with those four values is not found, then it should insert.
    MERGE INTO tb_slea_election_worksheet A
    USING 
    (SELECT i.slea_year,i.empid,i.bda_sum_sort,i.bda_dtl_sort FROM tb_slea_election_worksheet i
    WHERE  slea_year = '2008'
    AND empid = '6468T'
    AND bda_sum_sort = '30'
    AND bda_dtl_sort = '9999'
    ) B
    ON (A.slea_year = B.slea_year
    AND A.empid =B.empid
    AND A.bda_sum_sort  = B.bda_sum_sort
    AND A.bda_dtl_sort  = B.bda_dtl_sort) 
    WHEN MATCHED THEN
      UPDATE SET A.fa_proj_exp_amt  = 888
    WHEN NOT MATCHED THEN
      INSERT    (slea_year,empid,bda_sum_sort,bda_dtl_sort,act_exp_lst_yr,fa_proj_exp_amt)
      VALUES ( '2008','6468T','30','9999','0','55');

    A merge statement is just a much more efficient way of doing something like this pl/sql block
    DECLARE
       l_n NUMBER;
    BEGIN
       FOR r IN (SELECT pk, col1, col2 FROM source) LOOP
          BEGIN
             SELECT 1 INTO l_n
             FROM target
             WHERE pk = r.pk;
             UPDATE target
             SET col1 = r.col1,
                 col2 = r.col2
             WHERE pk = r.pk;
          EXCEPTION WHEN NO_DATA_FOUND THEN
             INSERT INTO target
             VALUES(r.pk, r.col1, r.col2);
          END;
       END LOOP;
    END;So, if the select from source returns no rows, nothing is going to happen.
    John

  • Why won't drag and drop work with Library Assets in Illustrator or InDesign?

    I've read a couple of threads with people having this issue, some dating back to late summer last year. I tried the fixes offered up in the responses, but haven't had success yet.
    All my programs are up-to-date, but I cannot drag and drop graphics from my library into InDesign or Illustrator. Photoshop is working fine.
    Are there any actual solutions to this yet?

    What kind of graphic are you talking about? In the Library panel (Illustrator) or CC Library panel (InDesign) graphics are identified with a small label to tell what their source is (Ai, ID, PS, SVG, etc.)
    And even though you say you have the latest version, exactly what version of InDesign do you have? You can see it in the About InDesign choice under the InDesign menu (Mac) or Help menu (Windows).

  • I have an ipad mini that won't power on. It was turned off to charge overnight. In the morning it was warm and now won't turn on no matter what I do. I've tried resetting using the power / home button combination and nothing works.

    I have an ipad mini that won't power on. It was turned off to charge overnight. In the morning it was warm and now won't turn on no matter what I do. I've tried resetting using the power / home button combination and nothing works.

    If you have owned the device, as in purchased from Apple, less than a year then there will be no charge to repair, or most likely, replace the device. If you have had the device more than a year you will be charged an out of warranty cost for replacement ($219 I think) and that is much cheaper than a new device. If you have Applecare+ then you have an additional year of coverage and the replacement will be $49 or $79 depending on when you got the Applecare.

  • Why won't 'Address and Search' from 'Customize Toolbar' box 'stick' when I drag it to my toolbar? I ran updates last night, and my Google searchbox disappeared and I can't get it back.

    Why won't 'Address and Search' from 'Customize Toolbar' box 'stick' when I drag it to my toolbar? I ran updates last night, and my Google searchbox disappeared and I can't get it back.

    Safari 6 ?
    URL address bar and Google search field are combined together in Safari 6.
    Apple calls it Smart Search field.
    There is no way to separate them.

  • Cant start up on my Macbook pro. All I get is a grey spinning wheel. Tried all the Startup key combinations and nothing works. I reset the NVRAM and nothing. I booted with start up disk , ran disk repair and all is ok. Tried to re-install OS but when I ge

    Can not start up on my Macbook pro. All I get is a grey spinning wheel. Tried all the Startup key combinations and nothing works. I reset the NVRAM and nothing. I booted with start up disk , ran disk repair and all is ok. Tried to re-install OS but when I get to designating drive its blank. When I go to startup disk there is a "?" mark. When I restart under startup disk search for a drive it still comes up with nothing.  Before I got the grey spinning wheel I had a locked screen. Could not move curser or click on anything. Finally just shut down. Thank you in advance for any help!

    Shouldn't still have a 'beachballing'... if the drive is being found and the system is trying to boot from it but is having problems, I would suggest looking over ds store's user tip - Step by step to fix your Mac.
    It's likely either something corrupt in your system files or a failing hard drive. But follow ds's steps until you find the cause of the problem.
    Good luck,
    Clinton

  • Why won't Log and Transfer in FCP7 recognize video files from my SD card? They were shot on a cheepo Aiptek camera.

    Why won't Log and Transfer in FCP7 recognize video files from my SD card? They were shot on a cheepo Aiptek camera.

    David, the camera shoots .mov files. I have the latest version of QuickTime installed but still nothing.
    I teach high school, but I'm reluctant to download FCPX for my students at the moment. I may try it but I really want to stick with what we're using currently, at least for now.
    iMovie started to import files, but very slowly. I guess I'm frustrated that the files shot on the Canons I also use transfer just fine, but the Aiptek camera isn't cooperating.
    Would you suggest using MPEG Streamclip?
    Thanks again in advance.

  • Why doesnt the youtube and imessege work on my ipad

    why doesnt the youtube and imessege work on my ipad

    For iMessages there is some troubleshooting on this page : http://support.apple.com/kb/TS2755
    Has the YouTube app previously worked on the iPad, and have you ever synced the iPad with your computer ? This page for YourTube (which refers to a "Cannot connect to YouTube" error message) says :
    To use certain services, iTunes must download and install an authentication token on the device. Because iPad and iPod touch do not require an active Internet connection to activate, these tokens may not be downloaded and installed during initial setup.
    You can resolve this issue by verifying that iTunes has an active Internet connection. Use the following steps:
    Open iTunes on your Mac or PC.
    Verify that your Mac or PC has an active Internet connection by accessing the iTunes Store in iTunes.
    Connect your iPad or iPod touch to your Mac or PC.
    After the sync completes, verify you can access YouTube.

  • Why won't my iTunes code work

    Why won't my iTunes code work helpppp

    Hi Benrad09,
    If you are having issues redeeming an iTunes Gift code, you may find the following article helpful:
    Apple Support: If you can't redeem your iTunes Gift Card or code
    http://support.apple.com/kb/HT6021
    Regards,
    - Brenden

  • Why won't Facetime and iMessage to verify and activate it ?

    Why won't Facetime and iMessage to verify and activate it ?
    Everytime I press next with both the apps. It brings me back to the Sign in page.
    Can someone please help me ?
    And i have the 5.1

    Same by me, any idea how to fix it? Have tryed allmoast everything.

  • HT4972 Why won't Kindle or instagram work on my I-Touch? Why do either of them require IOS 4 or 5?

    Why won't Kindle or instagram Apps work on my I-Touch?
    Why do either of them require IOS 4 or 5 and why can't Itouch V2 update to IOS 4 or 5 operating systems?

    1. The developer stopped supporting older iOS versions.
    2. A second generation iPod touch can be updated to iOS 4.2.1 but doesn't have enough RAM to run iOS 4.3 or newer.
    (82591)

  • WHY WON'T STICKY KEYS ACCESSABILITY WORK ON SAFARI/

    WHY WON'T STICKY KEYS ACCESSABILITY FEATURE WORK ON SAFARI? I AM A DOUBLE AMPUTEE AND THIS FEATURE REALLY HELPS ME.
    RANDY

    Do us all a favor, and unlock your Cap keys.  It's considered yelling, and it's a real turn-off for those looking to help posters here.

  • Why won't my podcast url work

    I wan't to know why my podcast rss won't play. All my episodes show up, but they don't connect and play, all of my files are m4a except one, it is mp3 and that one plays. Isn't m4a  the same as aac. But I can, dowload the episodes though, and they work, you just can't play or preview them in itunes.

    Hi suzique15,
    Welcome to the Apple Support Communities!
    There may be a few different troubleshooting steps I would recommend in this situation. Please read over and use the attached article for troubleshooting this situation with your enter key.
    One or more keys on the keyboard do not respond - Apple Support
    Best regards,
    Joe

  • Why won't my lock button work?

    I went to lock my iPod and my lock button won't work. I can't even push it down, it's like stuck down in the hole but it won't pop back up. Everything works fine but I have to wait for it to auto-lock everytime I want to turn it off. Why won't the button pop back up?

    It looks like you have a hardware issue. I don't know why the button doesn't pop up, but You can enable assistive touch. Assistive touch gives you a virtual lock button, so that will solve you problem. You can enable it by going to Settings->General->Accessibillity->AssistiveTouch->On.

Maybe you are looking for

  • How do I convert a selected nomber of pages from a pdf file?

    How do I convert only selected pages of a pdf file?

  • Problem creating in some attribute options for class through java API

    Hello everyone, I am successfully creating class and its attributes but i am not able to create attributes with its option like IS REQUIRED, IS INDEXED, IS SETTABLE and READ ONLY..... public void create_class(String cname,String cdesc,String scname)

  • Importing dvd's/music dvd's

    Does anyone know if music dvd's and movie dvd's can be imported to iTunes and then to the iPod? I have several I want to put in but I can't get it to work. Is there a program or a back door?

  • Material Requirement for non regular materials

    Hi, In case of MRP, we have some materials which have no regular consumption pattern. Therefore we cant predict the procurement plan through MRP run. Currently we are running these material by calculating the safety manually and uploading to the syst

  • CPU customazation

    Hello, Today i recieve this question and I want to hear your opinion as well. If i put the CPU in L ( Low Voltage) to preserver power, how this will affect the Database and the performance. CPU is: Intel Xeon DP Quad-Core L5410 2.33GHz Processor - BX