Control stmt CASE vs IF - Which is better

Hi,
I'm in the process of retrieving data from a table that has millions of rows. Now I need to count the numbers of rows where a particular field,TR_STATUS is either 'A','G' or 'K'. I have three different variables to hold the count on the rows with the respective values in the field, TR_STATUS I'm retrieving the rows into nested tables and am using a FOR loop, inside which a IF or a case should be written inorder to perform the count based on the value. From performance perspective, which one of these two control statements is preferred. please advise
Thanks

Or even
CREATE TABLE testtable AS
SELECT DECODE(TRUNC(DBMS_RANDOM.VALUE(1,4)), 1, 'A', 2,'B', 3,'C') AS tr_status
FROM   user_tables;
Table created.
SELECT SUM(DECODE(tr_status,'A',1)) AS count_a
     , SUM(DECODE(tr_status,'B',1)) AS count_b
     , SUM(DECODE(tr_status,'C',1)) AS count_c
FROM   testtable;
   COUNT_A    COUNT_B    COUNT_C
        12          6         11
1 row selected.orSELECT COUNT(DECODE(tr_status,'A','#')) AS count_a
     , COUNT(DECODE(tr_status,'B','#')) AS count_b
     , COUNT(DECODE(tr_status,'C','#')) AS count_c
FROM   testtable;
   COUNT_A    COUNT_B    COUNT_C
        12          6         11
1 row selected.Whatever you use though, SQL will be fast and slogging around a loop with IF statements will be slow.

Similar Messages

  • Which is better smart cover or snugg case

    hi i have both and i hate the snugg it makes the ipad look bad and takes the look away and i used the smart cover and i like it lot better so which is better smart cover or snugg case

    Personal preference. You just voted for the smart cover.
     Cheers, Tom

  • Which is better to use: BEx query or Web Application as an iView in portal?

    Hi gurus!
    Are there any experienced opinions, which is better - publish a BEx query in portal or publish a BEx Web Application in portal? Is it easier to alter the layout attributes etc. if I create a BEx Web Application first before publishing?
    What is the way of fixing for example filter item height if I publish BEx query in portal - is there a Web Application that it uses anyhow which I can fix? Or can I use in that case iView -properties in portal?
    Thankful for advice
    Sari

    ok, means i can use jsp:useBean tag for all my
    classes that are not actually bean. so it will be
    instantiated at run time and provide efficiency .No. Jsp:useBean is used for java bean components.
    >
    but when should i use import statement in my jsp and
    it happen at translation time so will it create any
    type of burden for my code if i import multiple
    classes.For non-java beans, you need to import the classes, period.
    It's not a burden, it's a necessity.

  • Which is better for performance Azure SQL Database or SQL Server in Azure VM?

    Hi,
    We are building an ASP.NET app that will be running on Microsoft Cloud which I think is the new name for Windows Azure. We're expecting this app to have many simultaneous users and want to make sure that we provide excellent performance to end users.
    Here are our main concerns/desires:
    Performance is paramount. Fast response times are very very important
    We want to have as little to do with platform maintenance as possible e.g. managing OS or SQL Server updates, etc.
    We are trying to use "out-of-the-box" standard features.
    With that said, which option would give us the best possible database performance: a SQL Server instance running in a VM on Azure or SQL Server Database as a fully managed service?
    Thanks, Sam

    hello,
    SQL Database using shared resources on the Microsft data centre. Microsoft balance the resource usage of SQL Database so that no one application continuously dominates any resource.You can try the 
    Premium Preview
    for Windows Azure SQL Database which offers better performance by guaranteeing a fixed amount of dedicated resources for a database.
    If you using SQL Server instance running in a VM, you control the operating system and database configuration. And the
    performance of the database depends on many factors such as the size of a virtual machine, and the configuration of the data disks.
    Reference:
    Choosing between SQL Server in Windows Azure VM & Windows Azure SQL Database
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • Which is better for bulk message scenario in sap xi RFC or Proxy

    which is better for bulk message scenario in ( RFC or Proxy ) ?
    Edited by: prabhatxi on Aug 6, 2010 4:44 PM

    Proxy will alwaays be better option in this case, as it is adapter less framework, and communication happens directly with XI central integration engine. So it is always fast communication and gives good performance.
    But still you should consider other factors, you may consider using RFC as well, as sometime we go for RFC/IDOC as this are the standard interfaces already available rather than creating structure...
    May be you can share more info on what type/volume data are you planning to send via XI?
    Hope this cleart your doubt..
    Divyesh

  • Which is Better Mac or Windows?

    Which is Better Mac or Windows?
    I got told that Windows is better than Mac.
    I need to know:
    1. How long an iMac lasts and how long a Windows computer last till they die and not work. (Prediction will do)
    2. Why lots of people hate Mac and say that Mac's are crap.
    3. Is a iMac worth the cost?
    4. Is an iMac harder to use than a Windows computer?
    Thank You
    From Apple is The Best!!!!!!!

    The case of Apple v. Windows is a subjective argument. Both systems have their merits, both have some aspects that some users don't like. Much depends on what you actually want to use them for.
    Here is some reading material for you!
    A Customer Experience Index report from Forrester Research came to the conclusion after studying almost 4,600 computer users' experiences from 2008 and asking them to score the ease of use of their computers, how enjoyable the experience is and whether or not the systems fulfill their owners' needs.
    http://www.appleinsider.com/articles/09/04/17/apple_trumps_windows_pc_makers_in_ customer_experience_study.html
    PC World (December 2010) has also found Apple products and after-sales service the most reliable:
    http://www.pcworld.com/article/211074/the_tech_brands_you_can_trust.html
    Switching from Windows to Mac:
    http://support.apple.com/kb/HT2514?viewlocale=en_US
    and
    http://support.apple.com/kb/HT2518?viewlocale=en_US

  • Which is Better? Mac or PC?

    Which is Better?
    Intel iMac   Mac OS X (10.4.5)  

    Hello,
    I'm not going to argue that a Mac is better, but I do have a response to:
    looking computers and the software is great however
    they have major compatibility issues. for example
    many websites do not support mac's Ex.
    www.aircanada.com
    I have never had any problem exchanging documents or viewing web pages with the Mac.
    All my document exchanges have worked flawlessly, and work going both to and from Windows PC's.
    But, you need to make sure you are using the right program on the Mac if you want to share files with PC users.
    As for the website compatibility, the site you provided as an example will work just fine. They just don't want you to know it.
    What that website is doing, is running a check to see what web-browser you are using. Beyond that, they are also running a check to see which computer you are using.
    So, what you need to do is make sure that your browser tells their website what it wants to hear.
    So, in Safari, you can use the "Debug" menu to have Safari report itself as the Windows version of Internet Explorer.
    Go to the Debug menu, then pick "User Agent", then choose: "Windows MSIE 6.0".
    If the site still won't load, then go to the site first, and perform the selection again from the Debug menu.
    Basically, what you are doing is changing what Safari identifies itself as.
    Additionally, the website that you listed does list that it is compatible with Mac OS 9.0 or later. So, it should work provided you pass it's checks.
    If for some reason it still won't work, contact them since they say that it is compatible with the Mac.
    The only sites that absolutely will not work with a Mac are sites that use "Active X" to take over control of your computer or communicate directly with the operating system. Fortunately, those sites are getting rarer and rarer.
    The only site I've run across in recent times that uses Active X is Microsoft's Windows Update site (which you wouldn't need with a Mac anyway).
    As for enabling the "Debug" menu in Safari, if it is not already there, you can do that by:
    Closing Safari
    Open "Terminal" which is located at:
    Hard Drive --> Applications --> Utilities --> Terminal
    Then type the following at the command line:
    defaults write com.apple.Safari IncludeDebugMenu 1
    If you would prefer an automated method of enabling the Debug menu, you can always download the free Safari Enhancer program which includes a setting for this feature:
    http://www.lordofthecows.com/softwarelist.php

  • Why assertion instead of if statement ?  Which is better to use ?

    Why assertion instead of if statement ? Which is better to use ?

    Never assertion instead of if statement. The two have fundamentally different intents. Using assert to control program flow is a bad idea

  • Coding Preference ..Which is better for memory?

    Hey all,
    Javas garbage collection is sweet. However, I was reading somewhere that setting some objects to null after I'm done with them will actually help.
    (help what .. I'm not sure.. my guess is memory used by the JVM)
    Thus I have two ways to do the same thing and I'd like to hear peoples comments on which is "better" ... or will yield faster performance.
    Task: I have a Vector of Strings (called paths) that hold absolute file paths. (Don't ask why I didn't use a String[]) I'd like to check and see if they exist, and if not, create them... I'll use the createNewFile() method for that.
    Method A -- Here I'll reuse that File object
    public void myMethod()throws Exception{
    File file = null;
    for(int i = 0; i < paths.size(); i++){
      file = new File(paths.get(i).toString());
      boolean made  = file.createNewFile();
      if(made){doSomething();}
    file = null;
    }Method B -- Here I'll use um... "dynamically made" ones that I won't eventually be set back to null
    public void myMethod()throws Exception{
    for(int i = 0; i < paths.size(); i++){
      boolean made  = (new File(paths.get(i).toString())).createNewFile();
      if(made){doSomething();}
    }So when the code eventually exists myMethod, the object "file" will be out of scope and trashed.... correct? If thats the case, then would there be any other differences between the two implementations?
    Thanks

    There's no real difference between the two. Choose the style you prefer,
    although in the first one I'd lose the "file = null" statement since that
    variable is about to disappear, and I'm move the definition into the loop
    -- always give variables as small a scope as possible, mainly to
    keep the logic simple:
    public void myMethod()throws Exception{
        for(int i = 0; i < paths.size(); i++){
            File file= new File(paths.get(i).toString());
            boolean made  = file.createNewFile();
             if(made){doSomething();}
    }

  • Blog or News - Which is better for SEO ?

    Recently I started using the Blog module to post articles about products that we manufacture (see link below)
    http://www.hammersmith.com.au/_blog/latest_news
    At the time of setting it up, I had a choice of using this module or the News module (known as "Announcements" back then). I went with the Blog module as I felt it suited me better, particularly with the opportunity for "comments" to hopefully play a part in increasing awareness of my products.
    One of my main aims of posting blog articles was to increase my SEO ranking by writing articles with key words that are relevant to products that we sell in our online shop.
    The "comments" side of the blog has attracted zero interest (apart from spammers !), so I am starting to think that it may be better in the future to use the News module, as it seems to provide more flexibility with controlling page titles and descriptions, which is important for SEO.
    I would appreciate any advice from the community in this matter.
    Cheers, Wyatt.

    I think that these 2 modules are pretty equal when it comes to SEO. However, if you control page titles in news you may want to use that module. Also, they have better URLs. The URL doesn't have /_blog/ in it and can be customised.
    That said, if you have an established blog already you can simply remove the comment form from the individual post layout and leaev the blog as is.
    -mario

  • Which is better Apple Ear Pods vs. In Ear Earbuds

    So which is better? I can't really tell the difference because there like the same. Unless I'm not paying attention to the bass and tremble.

    Haven't tried multiple EAR files before but encountered constraints when using one EAR file.
    For example, we may need to wait for another colleague to complete his portion on programming so that we can proceed to implement the entire EAR file. Is this also a constraint for multiple EAR files application ?
    If we can separate the EAR files into different modules, different colleagues can work on different modules concurrently. It could be more efficient... Is that the case ??

  • Singleton vs static - which is better?

    Of the two approaches -
    a class which can be used by accessing its ONLY instance(singleton) or a class which has a set of static methods which can be invoked on the class itself
    which is better and why? Or are these just two 'styles' of programming?
    I always get confused as to which way to go? I tend to prefer to have static methods on the class instead of a singleton.
    All insights/comments/ideas welcome.
    Thanks

    Well, there are a few questions you can ask - does the method cause any changes of state, or is it a pure function? If the latter, static is probably the way to go.
    The way you are talking, I gather that there is some state involved.
    Next question: does it make sense for there to be more than one of these per JVM? Not only in the way you currently envision it, but at all, anywhere. For example, consider the list of Strings that the String class keeps so it can consolidate memory and avoid duplication (see String.intern() ). That list makes sense to be static.
    On the other hand, the representation of the state of a board game should not be static, because someone could want to write a program which has multiple games within it - or you could within one game wish to have contingencies or undo-ability (essentially, it might not be as singleton as you think).
    Next, if you think the methods will ever need to be overridden, use a singleton, because static methods aren't, well, dynamic! (in case the singleton is a one-at-a-time singleton but it makes sense to have a change of identity over time).
    I have never written a true singleton - though often written classes which I did not PLAN on instantiating more than once.

  • Which is better,the Apple TimeCapsule or the WD MyCloud for backing up pixs and datas?

    I am not too sure which is better for backing up my pixs that i have saved and dont want to lose them,am thinking which would be best for me to purchase?the apple timecapsule or the wd mycloud,i heard great things about both but not sure from someone who got experience,so could u help me out and tell me which is better and why?
    thanks in advance...

    Backup is backup. Doesn't matter how you do it, but that you do it.
    Given the choice you posited I would choose the Time Capsule if you want to use Time Machine. If you wish to use third-party backup software then you can only use the WD. It comes with its own proprietary backup software. Or you can go another direction and avoid cloud/network backup which is very slow.
    Basic Backup
    For some people Time Machine will be more than adequate. Time Machine is part of OS X. There are two components:
    1. A Time Machine preferences panel as part of System Preferences;
    2. A Time Machine application located in the Applications folder. It is
         used to manage backups and to restore backups. Time Machine
         requires a backup drive that is at least twice the capacity of the
         drive being backed up.
    3. Time Machine requires a backup drive that is at least double the
         capacity of the drive(s) it backs up.
    Alternatively, get an external drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
      1. Carbon Copy Cloner
      2. Get Backup
      3. Deja Vu
      4. SuperDuper!
      5. Synk Pro
      6. Tri-Backup
    Visit The XLab FAQs and read the FAQ on backup and restore.  Also read How to Back Up and Restore Your Files. For help with using Time Machine visit Pondini's Time Machine FAQ for help with all things Time Machine.
    Although you can buy a complete external drive system, you can also put one together if you are so inclined.  It's relatively easy and only requires a Phillips head screwdriver (typically.)  You can purchase hard drives separately.  This gives you an opportunity to shop for the best prices on a hard drive of your choice.  Reliable brands include Seagate, Hitachi, Western Digital, Toshiba, and Fujitsu.  You can find reviews and benchmarks on many drives at Storage Review.
    Enclosures for FireWire and USB are readily available.  You can find only FireWire enclosures, only USB enclosures, and enclosures that feature multiple ports.  I would stress getting enclosures that use the Oxford chipsets especially for Firewire drives (911, 921, 922, for example.)  You can find enclosures at places such as;
      1. Cool Drives
      2. OWC
      3. WiebeTech
      4. Firewire Direct
      5. California Drives
      6. NewEgg
    All you need do is remove a case cover, mount the hard drive in the enclosure and connect the cables, then re-attach the case cover.  Usually the only tool required is a small or medium Phillips screwdriver.

  • Which is better for usb camera between VISA and imaqdx in labview 2010?

    i have done a program for usb camera to acquire images with imaqdx.
    now i want to know which is better between VISA and  imaqdx in labview 2010?
    i didn't study visa before
    thans for help.

    VISA is primarily used to communicate with instruments via GPIB/TCP-IP/Serial/USB. In order to use easily VISA with an instrument over USB the instrument must adhere to the USBTMC spec. A camera is not likely to have this. Otherwise you have to use USB RAW, and that requires detailed knowledge of the data that is transmitted by the instrument. Manufacturers rarely give this information out. Normally they will provide a DLL to communicate with the instrument.
    Thus, in your case, VISA is not going to be an appropriate API to use for a USB camera.
    Out of curiosity, what prompted this question?

  • Which is better and why a = new String("AA") or a = "AA"

    Hi,
    Which is better and why
    String a = new String("AA") or
    String a = "AA"
    Does invoking a construtor waste memory? Please explain in detail.
    Thanks in advance
    Deepak

    > So in case "AA" not there in string pool,
    That is not correct.
    does new creates "AA" on string pool as well as heap memory?Yes. The literal "AA" points to a pooled String object. The new operator creates a new String object with the same character sequence ("AA"). You can verify this with a little code...
    String s = new String("AA");
    assert s != "AA";
    assert s.equals("AA");
    assert s.intern() == "AA";~

Maybe you are looking for