How do I use the IF-ELSE condition in a WHERE clause?

I want to merge the condition results of my 2 If statements. First if statement result shows only both 0 result, in second if statement result one of them has to be bigger than 0... 
     If (Inventory) <> 0 Then
        If Apple = "" And Banana = "" Then
     strSQL = strSQL & " AND (myApple = 0 AND myBanana = 0)"
  End If
  End If
     If int(Inventory) <> -1 Then
  If Apple = "" And Banana = "" Then
     strSQL = strSQL & " AND (myApple <> 0 OR myBanana <> 0)"
  End If
  End If
**Want to get something like this**
     If int(Inventory) <> 0 Then
            If Apple = "" And Banana = "" Then
       strSQL = strSQL & " AND ((myApple = 0 AND myBanana = 0) AND (myApple <> 0 AND myBanana <> 0))"
    End If
    End If
    If int(Inventory) <> -1 Then
    If Apple = "" And Banana = "" Then
       strSQL = strSQL & " AND (myApple <> 0 AND myBanana <> 0)"
    End If
    End If
   myApple myBanana
         0       0
         0       0
         0       5
         1       0
         6       0
         0       0
      continue.....

Maybe
with
fruits as
(select null apple,null banana from dual union all
select 'Golden Delicious','Chiquita' from dual union all
select 'Granny Smith',null from dual union all
select null,'Cavendish' from dual
select apple,banana,nvl2(apple,1,0) * nvl2(banana,1,0)
  from fruits
APPLE
BANANA
NVL2(APPLE,1,0)*NVL2(BANANA,1,0)
0
Golden Delicious
Chiquita
1
Granny Smith
0
Cavendish
0
Regards
Etbin

Similar Messages

  • How can you use the ipad with lectures in uni where i can annotate my notes?

    How can i use my ipad fpr lectures in uni?

    There are tons of note taking apps. If you want one that records lectures, take a look at Auditorium.

  • The issue with using the multiple columns sub-query in WHERE clause

    Hi All,
    my database version is 10.2.
    the problem i am trying to deal with is that when I use multiple column sub-query in the WHERE clause of the SELECT statement, the actual row number returned from the sub-query is different from the whole statement.
    And what I found is that, whenever there is NULL in any of those columns returned from the SUB-QUERY, the outer query will just return NULL for that whole row.
    Here is an example:
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t;
    7782     CLARK     MANAGER     7839     09-JUN-81     2450     10
    7839     KING     PRESIDENT  NULL  17-NOV-81     5000     10
    7934     MILLER     CLERK     7782     23-JAN-82     1300     10
    select * from EMP where (EMPNO, ENAME, job, MGR, HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     If I specifically deal with the NULL situations for the columns which might return NULL, I can get the result right.
    select * from EMP where (EMPNO, ENAME, job, NVL(MGR,-1), HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, nvl(mgr,-1), hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  nvl(mgr,-1), hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7839     KING     PRESIDENT  null   17-NOV-81     5000          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     the problem is that, I feel this is a very lame way of handling it.
    So, I wonder or am asking if there is any better or standard way to do it?
    any help would be highly appreciated.
    Thanks

    Hi,
    As you discovered, INTERSECT treats NULL as a value, but IN does not.
    What you did with NVL is one way to handle the situation. If there was a chance that any of the columns could be NULL, then you might prefer something like this:
    select      *
    from      EMP
    where      ( EMPNO      || '~' ||
           ENAME      || '~' ||
           job           || '~' ||
           MGR           || '~' ||
           TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')
                    || '~' ||
           SAL           || '~' ||
           DEPTNO
         ) in (
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from     emp
             intersect
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from      t
             );This assumes that you can identify some string (I used '~') that never occurs in the strings in these tables.
    This is implicitly converting the NUMBERs. That's usually not a good thing to do. but explicitly converting them would make this even more tedious.
    You should explicitly convert any DATEs to strings, however. Depending on your default format, and your data, you might get away with implicit conversions even for DATEs, but don't bet on it.
    If you had to do this often, you might consider writing a user-defined function:
    delimited_string (empno, ename, job, mgr, hiredate, sal, deptno) would return a string like
    '7839~KING~PRESIDENT~~17-NOV-1981~5000~10'
    This will make the coding easier, but beware: it will make the execution slower.

  • I have an iTunes account with a $25.00 credit but everytime I go to purchase a song, it goes to my credit card details. How do I use the iTunes credit and not the credit card?

    I have an iTunes account with a $25.00 credit but everytime I go to purchase a song, it goes to my credit card details. How do I use the iTunes credit and not the credit card?

    Just to confirm, you are logged into the iTunes Store using the account in which the balance exists, and the balance is showing at the top of the iTunes Store window? And you're not trying to purchase gifts for someone else?

  • How do you use the Multiple Item Information dialog box ???

    How do you use the Multiple Item Information dialog box ???
    Where are the instructions on how the information in the Multiple Item Information dialog box equates to ...
    1. The way iTunes sorts tracks and albums
    2. The reason to select a leading check box
    3. Why there are Option selections (Yes /No) and leading check boxes.
    4. Why some changes remain in the track info, but do not "take effect" in iTunes (Part of a compilation is an example)
    Looked in Help, Support, went to the local Genius bar for an hour, even arrainged a call from apple support ...
    Thanks

    As Christopher says, it's a compilation. Different tracks are by different artists.
    Setting the *Album Artist* field to *Various Artists* and setting *Part of a compilation* to Yes should be all that is required. Depending on your *Group compilations when browsing* setting ( I recommend On ) either should suffice but I suggest doing both.
    Based on your commentary, I selected all the "O Brother" tracks, and checked the boxes for everything line that was blank in the Info and the Sort panes. Only exceptions were the album name and the disc number 1 of 1 and the artwork. I blanked and checked anything else.
    That's not what I meant. When you select multiple tracks, only those values which +are already common+ to all tracks are displayed. Typically these will include Artist, though not with compilation albums, Album Artist, Album, No. of Tracks, Genre plus various sort fields. A blank value may indicate that different tracks have different values or it may be that the value is blank for all tracks. For the drop down values on the Options tab the value shown may not reflect the information in every tag. If values you expect to be common, such as Album Artist or the Album title are not displayed you can simply type these in and click OK. This will often be enough to group the album.
    If you place a checkmark against the blank boxes and apply changes then you will clear those fields so you should only do this if that is the effect you want. Putting a checkmark next to an empty (representing different values) *Track No.* box, for example, will just clear the all the track numbers which is very rarely useful.
    Adding then removing extra text is for a specific problem where despite all common values being identical across the tracks of the album iTunes seems to "remember" that it should see two albums. A typical example would be when an album originally listed as *Album CD1* & *Album CD2* is given disc numbers X of Y and then has the Album name changed to Album. I've seen iTunes merge all but one track into the new album, but insist on listing one remaining track separately, despite both albums having the same title. In this case I've found overtyping the album title again has no effect whereas changing it to AlbumX and then back to Album does what I was trying to achieve in the first place.
    Don't forget that even properly organsied albums may still break up if you don't chose an album-friendly view. Sorting on the track name or track number columns can be useful in some circumstances but in general I revert to Album by Artist when browsing through my library.
    tt2

  • How do you use the bluetooth VIs with a Microsoft Bluetooth Driver?

    How do you use the LabVIEW Bluetooth VIs with the Microsoft Bluetooth driver?  I have been trying with no such luck.
       I want to use 2 computers to talk to each other using the bluetooth VIs.  Eventually, I think we would like a PDA/phone to talk to a custom built electronics board with Bluetooth.  But for now, I would just like 2 computers to talk and then eventually talk to our own device. 
    One is a desktop w/ the Belkin F8T012 USB adapter.  It installs fine with the Belkin driver (but I know I need to use the Microsoft Driver in order to use the LabVIEW VIs, but I have tried to get Windows to install its own but it says it is a BCM92045DG-Flash.  It says it cannot install it because it cannot find the necessary hardware.  I thought this USB adapter was on the approved Bluetooth devices list?  What else should I try?  Another Bluetooth USB adapter? 
    The other computer is a Dell Latitude 820.  It has a built in Bluetooth module which I believe is the Dell 350 Bluetooth Module.  On this machine I have been able to setup a COM port with a bluetooth device (blood glucose meter).  It came with a serial port interface which we modifed to go through a bluetooth interface.  It comes up as COM40. We have been able to communicate to it using their program originally designed to talk through a serial port.  But we would like to use the Bluetooth VIs in LabVIEW.  I can't even use the Discover VI.  Perhaps it is not using the Microsoft Driver as well.  Do I just uninstall the driver and then try to have Windows install its own driver?  Do you have any other recommendations?
    Thanks,
       Javi

    Hi Javi,
    This sounds like an issue with Windows and your specific Bluetooth devices.  As you mentioned, the LV Bluetooth VI's do require that the devices use the Windows drivers.  Take a look at this link for specific requirements for using Bluetooth with LabVIEW.  Also, you can take a look at our Developer Zone tutorial on designing Bluetooth applications a found here.  Regarding your device drivers, sometimes it is as easy as uninstalling the driver and then letting Windows discover the device and fine its own driver.  You could check out the Microsoft Knowledgebase for more information.  Thanks and have a great day!    
    Stephen S.
    National Instruments
    1 Test is worth 1000 expert opinions

  • How can I use the mousewheel to scroll forward and back in Safari?

    I really like Safari. As I see it, the only short coming is a feature that is present in Internet Explorer and Firefox. In both of these applications I can hold down a modifier key (CTRL) and roll the mouse wheel to go back 1 page in history. I would be really glad to know how to do this in Safari, as just about everything else I can do in IE and Firefox is in Safari. This roll back feature is one of the things I use more often than almost anything else.
    Question: How can I use the mousewheel to move backward in the browser history?

    Yes, I could move my hand from the mouse to keyboard to use a key combo... I could even use the delete key... but it's not really as effient as using the mouse's scrollwheel. Not that it's really all that bad, since Firefox is a great browser, but am I stuck with it if I want that one solitary additional feature?

  • How can I use the speakers from my old iMac (with miniRCA? plug) on a new iMac

    How can I use the speakers (M-Audio) from my old 24" iMac on a new 27" iMac?  There is no jack on the new iMac - is there an adapter that will use the mini-RCA (?) plug from my old speakers to connect them to a new iMac?  Thanks ...

    Thanks again!
    Hmmm ... I wonder.  The input jack for external speakers quit working on my old iMac (it made lotsa static noise for a while when I moved the plug or computer, then quit working completely; I figure something inside the computer got loose or crapped out - and I'm too cheap/lazy to take it the 20 miles to the nearest shop that might fix it).  When I plug the speakers into the headphone jack on the old iMac, I get very low volume or just one channel.
    I don't have the new iMac yet, but I was hoping to use these old speakers instead of buying new ones.  I will certainly try your solution - what do I have to lose?  If they don't work, then I get new ones - or try something else.
    Many thanks for your time!

  • E71 - how can i use the gps, please help

    I have never used GPS before, i got E71 last week, it says in the manual that there is an inbuilt gps receiver in it.
    From the discussion here it looked like i still need something else to use the GPS. I saw someone
    mentioned 'Mapping', does E71 come with this program or do i need to get it from somewhere?
    Can someone tell me how i can use the GPS in the E71? Is it possible to use gps in this phone without paying additional charges?
    Many thanks.
    Solved!
    Go to Solution.

    Phones with free navigation
    Nokia E72
    Nokia E71
    Nokia E66
    Nokia N97 mini Gold Edition
    Nokia N97mini
    Nokia N97
    Nokia N86 8MP
    Nokia X6 16GB
    Nokia 5800 XpressMusic
    Nokia 5235 Ovi Music Unlimited
    Nokia 5230
    To find Ovi Maps for other phones visit Maps Support-http://www.nokia.co.in/get-support-and-software/download-software/maps-support/compatibility-and-dow...
    How to install and setup GPS in nokia E-71.
    Firstly Install Nokia Ovi Suite (advance version of PC Suite) in your respected computer.
    http://www.nokia.co.in/get-support-and-software/download-software/nokia-ovi-suite
    After installation of Nokia Ovi Suite go to following link
    http://www.nokia.co.in/explore-services/ovi-maps/downloads?intc=ncomexpserv-fw-ilc-lft-con-na-ncomex...
    Now install the the second link file into your phone, i.e., "nokia_maps_3.03_10wk11_b04_s60_3.1_rom.Nocs.sis".
    After successful installation connect your phone with data cable in PC Suite (DON'T run PC suite application in your system) mode and open Nokia Ovi Suite application in your system.
    Now in Nokia Ovi Suite application click on View-Go to-Maps (make sure your system is connected to Internet and your mobile phone key pad doesn't get locked, if keypad autolock period is on switch it off for that moment and your phone is fully charged, now in maps select Asia in that India and download that India Map (103 MB) into your phone.
    Please Note that do not disconnect your phone from data cable else maps will not get downloaded and will not to be
    transferred to your phone.
    After successful installation of maps into your phone download "Voice Guidance Languages", which ever is preferred by you, if you really want to enjoy it. Like- English(UK)-with street names or in Hindi, Tamil, Urdu.
    Now you are almost done, just take your phone into your hand,
    Go to Maps then select Options-then Settings
    Internet-Connection-Offline ( don't worry your GPS will work fine as data bearer is Nokia which is free of charge, so just relax).
    Navigation-Drive Guidance-Select the desired Voice
    Walk Guidance-Select the desired Voice or you can set it to Beeps and Vibrations (if downloaded).
    Home Location- define you home location by searching in maps, this will make easier to drive back to home by simply selecting Drive Home option while using navigation.
    Now go to option Map-Categories-select the categories you want to be shown on the map.
    Its DONE, now search for any desired location press the selection button and then select Drive to or Walk to option and you will be connected to GPS.
    Please Note as GPS needs free environment so it may not work in home and generally it takes 10-15 minutes to connect so please be patient.

  • How can i remove the terms and conditions from my app store on iphone 5s ?

    How can i remove the terms and conditions from my app store icon on iphone 5s

    Hello mrh1962,
    Thank you for providing the details of the issue you are experiencing with accepting Terms & Conditions on your iPhone 5s.
    First, I recommend restarting your phone and then resetting if it's still not working:
    Restarting your device
    Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider.
    Press and hold the Sleep/Wake button until the Apple logo appears.
    Note: Reset your device only if you are unable to restart it.
    Resetting your device
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears.
    You can find the full article here:
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    If you can access your home screen, I also recommend verifying that cookies are not blocked and private browsing is turned off in Settings>Safari:
    iPhone User Guide - Safari settings
    http://help.apple.com/iphone/7/#/iph3d7aa74dc
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • JPA - How can I use the table's default Date types? e.g. CURRENT_TIME

    Once again, can't find an answer anwhere.
    I would like to know if/how one can use the default date/time/datetime types as declared for the target table when attempting to persist an entity having these fields set as null.
    create table item
         item_id INTEGER NOT NULL PRIMARY KEY DEFAULT AUTOINCREMENT,
         date_created DATETIME NOT NULL DEFAULT NOW(*),
         date_updated DATETIME NOT NULL DEFAULT NOW(*),
    );Now how can I get the above table to work when attempting to em.persist(myItem) whereby dateCreated and dateUpdated are both null?

    I should also mention that TopLink has always supported the ability to retrieve the current time from the database for use in optimistic locking. The TimestampLockingPolicy offers the ability to configure the next value being retrieved from the database instead of using the local time from the JVM. Our extended optimistic locking configuration does not currently support setting this option but it could be done using a descriptor customizer which can be configured in your persistence unit properties.
    Using optimistic locking may be a good solution for the last modified date since it will also ensure that you do not corrupt the database if someone else has incremented this value since your last read.
    Doug

  • How can i use the boolean AND here?

    Hi,
    how can i use the boolean expression AND in order to include it in the expression below so as that 2 condition must be true in order to get the respective data from the database?
    java.sql.ResultSet res = statement.executeQuery("SELECT * FROM station9 " + "WHERE P =" + power);
    regards

    java.sql.ResultSet res = statement.executeQuery("SELECT * FROM station9 " + "WHERE P =" + power + " AND FLAVOUR = " + raspberry);

  • How do I use the 'mv' command??

    I want to move some scripts file into my /User/Local/Bin/
    folder but i cant i get
    usage: mv [-f | -i | -n] [-v] source target
           mv [-f | -i | -n] [-v] source ... directory
    and i dont know what else to do because i really need to move the files.
    So far this is the way im doing it
    sudo mv encode-handheld-5.2.pl /User/Local/Bin/
    And when I do that I get this message...
    mv: rename encode-handheld-5.2.pl to /User/Local/Bin/: No such file or directory
    How do I use the mv command or how am i supposed to mv those files.??
    Help Please!

    You are still not providing the path to the file you're moving.  Did you read my earlier response?  Are you sure this file is in the current working directory?  Try the "ls" command (that's lowercase "LS").  Do you see that file?  If not, follow my earlier directions.
    As to whether the /usr/local/bin directory exists, it should, but you can check with:
    ls -al /usr/local/bin
    If you get an error, the directory does not exist for some reason, which means your system is in an uncertain state.
    BTW, meaning no offense, if you don't know all this stuff, you should be very, very cautious when using the Terminal.  It is a very dangerous place to those who don't have some idea what they're doing.  You can irreparably damage your system (requiring a reinstall) and even destroy your data with very minor typos.

  • How do I use the Japanese fonts in Font Book in a Pages document?

    How does one use the Japanese fonts in Font Book in a Pages document. Pages has its own fonts but I cannot get the Japanese fonts into it.

    To type japanese on a computer you change the keyboard, not the font.  Go to system prefs/keyboard/input sources and add Japanese/Kotoeri to the list, then select Hiragana in the "flag" menu at the top right of the screen, then type.  The font will take care of itself.
    http://redcocoon.org/cab/mysoft.html
    If you have any further questions, just ask.

  • How do I use the web cam on my pc? Hp w2007 I have windows vista

    How do I use the web cam on my pc?  Hp w2007 I have windows vista

    Hp w2007 is a HP monitor without webcam ...
    Where is the webcam?
    V.
    *** Say 'Thanks' with Kudos ***

Maybe you are looking for

  • JMS Content Conversion with spaces

    Hi I am using the JMS Content Conversion to transalte MQ messages ( they come from the Mainframe ),to XML Format. These messages are in fixed lenghts structure , the fields contain blanks (spaces) The adapter cannot deal with it,only fixed lenghts wi

  • Isight and Elluminate

    I am attempting to use elluminate for classroom video chat. When I turn on the video support, it comes up "video input not supported". Their tech support simply tells me to make sure it is plugged in and drivers installed. Specifically, they state th

  • I wish to review my response to the "Apple may periodically collect..." window when an Application crashed?

    I got one of those "Apple may periodically collect..." windows when an Application crashed on me, and I selected to report the crash. I've not seen this window before and I hit return before I had a chance to read it.  Now I realize that I had the ch

  • Where to define .rpt file location in Crystal Report Server 2008

    Hi all, I have installed Crystal Report Server 2008 in my machine and trying to invoking the report from my java application. Earlier we have used Crystal Report Server XI Release 2 and in my java application i am passing crystal report server name,

  • Compensation Approval

    Hello Experts, when i click on Approve or Reject button after selecting employee in Compensation Aprrovel iview i am getting an error:RFC error; Hr_Ecm_Ui_Get_Proc_Prep_Data - Is_Ok returned false. Check the log to resolve the error anyhelp. Please h