I HAVE A QUESTION ABOUT USING CASE STRUCTURE

Can I compute a percentage using case structure?
In the following query below, I have been able to use CASE STRUCTURE to add to a counter when days were between 0 and 30, or when days were between 31 and 60 or when days were between 61 and 90 or when days were between 91 and 9999. I have also been able to get a GRAND TOTAL of all days between 0 and 9999. This is done in the LAST ITEM of the SELECT STATEMENT. The FIRST ITEM of the SELECT STATEMENT counts rows of records being processed. I want to take the LAST ITEM of the SELECT STATEMENT and MULTIPLY it by 100 and then DIVIDE it by the FIRST ITEM of the SELECT STATEMENT to get a percentage. I know that you can do this with numeric fields in a file but is there a way to do this in CASE STRUCTURE with calculated totals?
SELECT
count(distinct v.rowid) v_cnt,
SUM(CASE WHEN(V.LCL_ER_RECV_DT - ADD_MONTHS(V.IND_ER_PER_END_DT,3)) BETWEEN 0 AND 30 THEN 1
ELSE 0
END) one_mo,
SUM(CASE WHEN(V.LCL_ER_RECV_DT - ADD_MONTHS(V.IND_ER_PER_END_DT,3)) BETWEEN 31 AND 60 THEN 1
ELSE 0
END) two_mo,
SUM(CASE WHEN(V.LCL_ER_RECV_DT - ADD_MONTHS(V.IND_ER_PER_END_DT,3)) BETWEEN 61 AND 90 THEN 1
ELSE 0
END) three_mo,
SUM(CASE WHEN(V.LCL_ER_RECV_DT - ADD_MONTHS(V.IND_ER_PER_END_DT,3)) BETWEEN 91 AND 9999 THEN 1
ELSE 0
END) three_pl_mo,
SUM(CASE WHEN(V.LCL_ER_RECV_DT - ADD_MONTHS(V.IND_ER_PER_END_DT,3)) BETWEEN 0 AND 9999 THEN 1
ELSE 0
END) TOT
FROM NCOER V, NCOER_IN_ERROR NIE, NCOER_ERROR NE, ALL_CMD_VIEW ACV
WHERE V.MIL_CMD_ASGN_CD IN ('FC')
and v.lcl_er_form_cd = '4'
and acv.cmd_cd = v.mil_cmd_asgn_cd
and nvl(acv.lcl_code_stat,'N') = 'Y'
and NVL(v.lcl_omit_from_stats_ind,'N') <> 'Y'
AND V.PSC_CD IN ('FS10')
AND (V.LCL_ER_RECV_DT >= '01-MAR_2007' AND V.LCL_ER_RECV_DT <= '31-MAR-2007')
AND V.IND_SSN = NIE.IND_SSN(+)
AND V.IND_ER_PER_END_DT = NIE.IND_ER_PER_END_DT(+)
AND V.LCL_ER_RECV_DT = NE.LCL_ER_RECV_DT(+)
AND V.IND_SSN = NE.IND_SSN(+)
AND V.IND_ER_PER_END_DT = NE.IND_ER_PER_END_DT(+)
AND V.LCL_ER_RECV_DT = NE.LCL_ER_RECV_DT(+)

Solution for you:
SELECT
COUNT(V_CNT) PROCESS_RECORD,
SUM(CASE WHEN(PROCESS_MONTHS) BETWEEN 0 AND 30 THEN 1
ELSE 0
END) ONE_MO,
SUM(CASE WHEN(PROCESS_MONTHS) BETWEEN 31 AND 60 THEN 1
ELSE 0
END) TWO_MO,
SUM(CASE WHEN(PROCESS_MONTHS) BETWEEN 61 AND 90 THEN 1
ELSE 0
END) THREE_MO,
SUM(CASE WHEN(PROCESS_MONTHS) BETWEEN 91 AND 9999 THEN 1
ELSE 0
END) THREE_PL_MO,
SUM(CASE WHEN(PROCESS_MONTHS) BETWEEN 0 AND 9999 THEN 1
ELSE 0
END) TOT,
(SUM(CASE WHEN(PROCESS_MONTHS) BETWEEN 0 AND 9999 THEN 1
ELSE 0
END) *100/COUNT(V_CNT)) TOT_PER
FROM
(SELECT     V.ROWID V_CNT, V.LCL_ER_RECV_DT - ADD_MONTHS(V.IND_ER_PER_END_DT,3) PROCESS_MONTHS
FROM     NCOER V, NCOER_IN_ERROR NIE, NCOER_ERROR NE, ALL_CMD_VIEW ACV
WHERE     V.MIL_CMD_ASGN_CD IN ('FC')
AND     V.LCL_ER_FORM_CD = '4'
AND     ACV.CMD_CD = V.MIL_CMD_ASGN_CD
AND     NVL(ACV.LCL_CODE_STAT,'N') = 'Y'
AND     NVL(V.LCL_OMIT_FROM_STATS_IND,'N') <> 'Y'
AND     V.PSC_CD IN ('FS10')
AND     (V.LCL_ER_RECV_DT >= '01-MAR-2007' AND V.LCL_ER_RECV_DT <= '31-MAR-2007')
AND     V.IND_SSN = NIE.IND_SSN(+)
AND     V.IND_ER_PER_END_DT = NIE.IND_ER_PER_END_DT(+)
AND     V.LCL_ER_RECV_DT = NE.LCL_ER_RECV_DT(+)
AND     V.IND_SSN = NE.IND_SSN(+)
AND     V.IND_ER_PER_END_DT = NE.IND_ER_PER_END_DT(+)
AND     V.LCL_ER_RECV_DT = NE.LCL_ER_RECV_DT(+) )
Regards,
Rajs
www.oraclebrains.com

Similar Messages

  • I have a question about using multiple ipads in our school.  Each of our teachers have a iPad and AppleTV in their classroom.  The issue is, with our classrooms so close in proximity to one another, is there a way to pair teacher

    I have a question about using multiple ipads in our school.  Each of our teachers have a iPad and AppleTV in their classroom.  The issue is, with our classrooms so close in proximity to one another, is there a way to pair teacher #1 iPad to its AppleTV without effecting/projecting onto the adjacent teachers #2 classroom AppleTV?

    Not as such.
    Give the AppleTV units unique names and also enable Airplay password in settings with unique passwords for each teacher.
    AC

  • Hi, I have quick question about use of USEBEAN tag in SP2. When I specify a scope of SESSION for the java bean, it does not keep the values that I set for variable in the bean persistent.Thanks,Sonny

     

    Make sure that your bean is implementing the serializable interface and that
    you are accessing the bean from the session with the same name.
    Bryan
    "Sandeep Suri" <[email protected]> wrote in message
    news:[email protected]..
    Hi, I have quick question about use of USEBEAN tag in SP2. When I
    specify a scope of SESSION for the java bean, it does not keep the
    values that I set for variable in the bean persistent.Thanks,Sonny
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • I have a question about using adobe CS files in CS6 edition

    I am a graphic artist . I have a question about using adobe CS files in CS6 edition. when I am gonna open thse adobe CS created files in CS6 Edition i get a color variation than i made with the CS version.Please give me an idea about this issue as soon as possible.If you need i can upload my problem as a screenshot to clearity

    donrulz,
    Are your Edit>Color Settings the same?
    Are you using spot colours, such as Pantone (there have been some changes in CMYK values with new colour books)?

  • Have a question about using javabean in jsp

    Hello,
    Could I have a constructor with arguments in javabean?
    Thanks.

    Yes, but if you want to instantiate the bean using that constructor you have to do it in a snippet of java code, not using a jsp tag:
    You can use
    <%
    MyBeanClass mbc = new MyBeanClass(arg1, arg2, ...);
    %>You can't use
    <jsp:useBean id="mbc" class="MyBeanClass">

  • Have a question about  using functions  in JSP 2.0

    Hello,
    Does someone try to create functions in JSP2.0?
    the following codes is from http://developer.java.sun.com/developer/technicalArticles/javaserverpages/JSP20/
    Code Sample:math.jsp
    <%@ taglib prefix="my" uri="http://jakarta.apache.org/tomcat/jsp2-example-taglib %>
    <HTML>
    <HEAD>
    <TITLE>Functions</TITLE>
    </HEAD>
    <BODY>
    <H3>Add Numbers</H3>
    <P>
    <FORM action="math.jsp" method="GET">
       X = <input type="text" name="x" value="${param["x"]}">
       <BR>
       Y = <input type="text" name="y" value="${param["y"]}">
       <input type="submit" value="Add Numbers">
    </FORM>
    <P>
    The sum is: ${my:add(param["x"],param["y"])}
    </BODY>
    </HTML>Compute.java
    package jsp2.examples.el;
    import java.util.*;
    public class Compute {
       public static int add(String x, String y) {
          int a = 0;
          int b = 0;
          try {
            a = Integer.parseInt(x);
            b = Integer.parseInt(y);
          }catch(Exception e) {}
          return a + b;
    }I put function tags in C:\Tomcat\webapps\jsp-examples\WEB-INF\jsp2\jsp2-example-taglib.tld
      <function>
            <description>add x and y</description>
            <name>add</name>
            <function-class>jsp2.examples.el.Compute</function-class>
            <function-signature>int add(java.lang.String,java.lang.String)</function-signature>
        </function>But get the error messages:
    The server encountered an internal error () that prevented it from fulfilling this request.
    org.apache.jasper.JasperException: /jsp2-tutorial/math.jsp(11,22) equal symbol expected
    Am I missing somethig?
    Thanks.

    Well, i think the code is perfectly fine , what you should look after : is there any servlet.jar exist in the jre/lib/ext on you java sdk ,you can determine whether EL 2 works by trying some jsp 2 examples provide with tomcat 5 alpha version .
    If it works , then it is not the alternative servlet.jar issue , most probably is your configuration errors.
    I have try my custom function and it worked well under tomcat 5 after resolving the earlier servlet.jar issue.
    By the way you don't have to put your tld file as described , simply place it under your /WEB-INF and edited your tomcat 5 web.xml to like my example given below .
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
    version="2.4">
    <display-name>Display Name of the application</display-name>
    <description>
    application name
    </description>
    <jsp-config>
    <taglib>
    <taglib-uri>
    your tld file
    </taglib-uri>
    <taglib-location>
    /WEB-INF/your tld file.tld
    </taglib-location>
    </taglib>
    </jsp-config>
    </web-app>
    Please give it a try and let me know whether it works , I will provide more assistance if required.

  • Question about using TVARV in an ABAP program

    Hello gurus, Im sorry about the silly question.
    I have a question about using TVARV in an ABAP program.
    A program is presenting a problem and I think that in this code:
    SELECT SIGN OPTI LOW HIGH
      FROM TVARV
      INTO TABLE R_1_163431035_VELOCIDADE
      WHERE  NAME = '1_163431035_VELOCIDADE'
      AND    TYPE = 'S'.
      IF ZMM001-VELOCIDADE_B   IN R_1_163431035_VELOCIDADE AND
          ZOPERADORAS-OPERADORA = 'ABCD' AND
          ZMM001-MATERIAL       IN R_1_163431035_PRODUTO.
      ELSE.
      ENDIF.
    What happens is that the value "ZMM001-SPEED" B not exist in "R1_163431035_VELOCIDADE" but the program executes commands under the IF and not under the ELSE, as I imagine it would work. Is this correct ?
    I am new to ABAP programming, but I have a lot of XP in other programming languages ​​and this makes no sense to me.
    Anyone know where I can find some documentation of the use of "TVARV" in ABAP programs?
    I search the Internet if other programmers use TVARV this way, but found nothing, which leads me to think that was a quick and dirty solution that used here.
    If this is a bad way to program, what would be the best way?
    Regards
    Ronaldo.

    Hi Ronaldo,
    But in this case, the range is not empty, there are 17 records, in this way.:
    For the column "SING" all values ​​are "E"
    It means that the result is false if ZMM001-VELOCIDADE_B has the same value as one of the 17 records (E = exclude).
    For instance, if it has value 'C' and one of 17 records matches C, then the result is false.
    The "IF" with "IN" using "TVARV" as used in the program of the post above has the same behavior of a selection screen?
    Yes, the same behavior as the selection criterion to be exact. You can press the help key in the complex selection dialog for more info.
    I know it's a silly and very basic question, but other language that I used, only the SQL has the "IN" operator, but I think they work in different ways, so I would like to understand how it works in ABAP.
    Not silly ;-). Yes they work differently.
    More info here:
    - http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba74635c111d1829f0000e829fbfe/frameset.htm
    - http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/frameset.htm
    BR
    Sandra

  • Question about using new battery in old Powerbook

    I have a pre-intel Powerbook G4, and the battery is pretty much toast (lasts about 15 minutes now). I have ordered a new battery for it, and I have this question about using it:
    Am I smarter to keep the new strong battery out of the PB most days (as I usually work with it plugged in at home) and just pop it in when I know I will be out surfing on batteries? Or is it just as good living in my laptop 24/7 and only occasionally being called upon to do its job?
    Current bad Battery Information below:
    Battery Installed: Yes
    First low level warning: No
    Full Charge Capacity (mAh): 1144
    Remaining Capacity (mAh): 1115
    Amperage (mA): 0
    Voltage (mV): 12387
    Cycle Count: 281
    thanks folks, Shereen

    Hi, Shereen. Every Powerbook battery wants to be used — drained and then recharged — at least every couple of weeks. If you've always used your Powerbook on AC power nearly all the time, and not followed that pattern of discharging and recharging the battery every week or two, it's possible that your use habits have shortened the lifespan and prematurely diminished the capacity of your old battery. Of course it's also possible that your battery is merely old, as a battery's capacity also diminishes with age regardless of how it's used. You didn't say how old the battery is in years, so this may or may not be an issue. I mention it only because it can be an issue.
    For general information on handling a battery for the longest possible lifespan, see this article. My advice on the basis of that article and long experience reading these forums is that it would be OK to do as you propose, but I doubt that you'd derive any significant benefit from it. You would still want to be sure of putting the new battery through a charge/discharge cycle every week or two, even if you didn't have a reason to use the Powerbook away from home or your desk, because sitting unused outside the computer is just as bad for a battery as sitting unused inside it. And you should never remove the battery from your computer when it's completely or almost completely discharged and let it sit that way any longer than a day or two.
    Message was edited by: eww

  • Question about using Macbook in Vietnam.

    I have a question about using Macbook in Vietnam. I bought my mac here in the US, and I'm going to visit Vietnam, but I'm wondering if I can plug in the power directly into the wall or I have to need any convert power modem for my mac. The only thing I know that Vietnam use 220V so, can anyone help me?

    You may need a plug adaptor, but you don't need a power converter.
    (43828)

  • Question about using Runtime.getRuntime();

    hi all
    i have a question about using Runtime.getRuntime(). if i use this to get a runtime reference to run an external program, is it considered as starting a new thread inside the thread that starts it?
    is it safe to do it in the Session EJB? if not, what can you recommand to do it? thanks

    hi all
    i have a question about using Runtime.getRuntime().
    if i use this to get a runtime reference to run an
    external program, is it considered as starting a new
    thread inside the thread that starts it? No. Starting a process, starts a process. Threads have nothing to do with it.
    is it safe to do it in the Session EJB? if not, what
    can you recommand to do it? thanksSo what? Run another process? If you want to run another process in java then your choices are to use Runtime.exec() or use JNI. And using JNI will probably end up doing exactly the same thing as Runtime.exec().
    "Safe" is harder. Typically to correctly use Runtime.exec() you must use threads. And as noted threads ideally should not be used. You can use them but if you do you had better understand why they didn't want you using them in the first place. You had also better be sure that you really want to wait for it to complete.
    Other than that Runtime.exec() is safe because it can't crash the VM like other interfaces can (like JNI.)

  • I have a question about japan new depriciation engine using non-japanese chart of deprication

    Hi, all
    I have a question about link between new depriciation engine and chart of depriciation.
    My client want to use US chart of depriciation as standard chart of depriciation becuase it has already standard setting like IAS deprication keys.
    it means I have to create Japanese chart of depriciation by copying from US chart of depriciation(non-japanese sample(0JP))
    I have a little doubt about it. In my previous project, I copyed chart of depriciation by copy from Japan sample Chart of depriciation(0JP) stored in SAP.
    Is it possible to copy from non-japan sample charg of depriciation to using Japanese new depriciation engine? I worried some errors will occrues if I do not use sample chart of depriciation(0JP) .
    If I need to use sample Japanese chart of depriciation, please give me the idea why I need to use Japanese sample chart of depriciation. I want to know the examples of non-Japanese asset accouting consultants who have working experience in the area.
    Thank you.

    Hi, Narasimhulu
    Thank you for your support.
    My client use one COA to all over the world. And not only Japan, other country aslo use the COD which is copied from that of US. Basic reporting line is for USGAP. I will customize 2 depriciation ares, one for US GAP and another is JGAP. No need to create TAX realted customize.  It means it enought only adding Japanese new depriciation keys to Current US COD. No need to add more Japanese local requirements.
    In this case, I want to know follwoing point.
    I know COD controll depriciation keys, but I want to know more detail about COD, what kinds of controls COD do. What is Japanese local requirements. Why better to use COPY of JP COD.
    Thank you.

  • I have a question about Lightroom 5... I used it last night, I go to get on it today and its will not open. I have an error msg "Lightroom encountered an error when reading from its preview cache and needs to quit" Lightroom will attempt to fix the proble

    I have a question about Lightroom 5... I used it last night, I go to get on it today and its will not open. I have an error msg "Lightroom encountered an error when reading from its preview cache and needs to quit" Lightroom will attempt to fix the problem when reopened

    https://forums.adobe.com/message/6219922#6219922
    See if the issue in the thread above helps you to solve your problem.

  • Hello am using ios 7.0.4 I have a question about messages that it does not show the time of a particular message after first message that I recive form a paricular person so please in the next version change this and with every message show time and date

    hello am using ios 7.0.4 I have a question about messages that it does not show the time of a particular message after first message that I recive form a paricular person so please in the next version change this and with every message show time and date

    Hi,
    How is everything going? Have you checked this issue from OWA? If so, please let me know the result.
    In adition, please also try to use the following powershell commands to check if the assistant has right permissions:
    Get-MailboxFolderPermission -Identity
    CEO’s email address:\Calendar -User assistant’s email address
    Also check with:
    Get-Mailbox -Identity CEO’s mailbox
    | fl *GrantSendOnBehalfTo
    Please let me know the result.
    Best Regards,
    Steve Fan
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Question about Using PAPI Web Service in PowerBuilder 9

    Hi, all.
    I Have a simple question about using papiws in power builder 9.
    In pb9, I created a new Web Service Proxy Wizard and I input a url for papiws(ex. http://seraphpernote:7001/papiws/PapiWebService) and click next.
    But I couldn't get any Service List.
    In Eclipse, I used this url for using papiws well.
    Does anybody know about this case??
    help me plz.

    IIRC you must activate PAPI-WS for the engine. In Studio you do it by right-clicking on the project, then "engine preferences". In enterprise/standalone you must activate PAPI-WS in the Admin Center.

  • Hi I have a question about shooting in Raw with my Canon EOS 6d. I'm in the process of learning photography and my goal was to start shooting in raw. I have Photoshop CS5. When I tried to edit my images in raw I received an error message stating, "The pho

    Hi I have a question about shooting in Raw with my Canon EOS 6d.
    I'm in the process of learning photography and my goal was to start shooting in raw.
    I have Photoshop CS5. When I tried to edit my images in raw I received an error message stating, "The photoshop camera raw plug-in did not recognize the format. If these files are from a camera, you may need to update your camera raw plug in."
    In researching the issue I read that to edit in raw you need a camera model requirement of at least 7.3 which only works with CS6. My version of CS5 is 6.0.0.205. Being new to all this I see that my options are to upgrade to CS6 or convert by using DNG converter and paying a monthly fee. Two things I know nothing about and don't know which is would be more beneficial.
    I'd appreciate any advise on which route to go and how upgrade and what it may cost. THANKS in advance!
    Heather

    In researching the issue I read that to edit in raw you need a camera model requirement of at least 7.3 which only works with CS6.
    That is correct. Your camera was first supported by Camera Raw 7.3. Camera Raw 7.3 will not work with CS5. You need CS6 or CC.
    Being new to all this I see that my options are to upgrade to CS6 or convert by using DNG converter and paying a monthly fee. Two things I know nothing about and don't know which is would be more beneficial.
    I'd appreciate any advise on which route to go and how upgrade and what it may cost.
    It all depends on your preferred workflow and your budget.
    Using the DNG converter is free. There is no monthly fee. You use the converter to convert all Raw files from the EOS 6D to DNGs then edit the DNGs in CS5. That's an extra step every time - every photo. Some people don't like the extra step. Others don't mind.
    Camera raw, DNG | Adobe Photoshop CC
    Or you can upgrade to CS6 (non-Cloud) and pay the upgrade fee
    Creative Suite 6
    Or join the Cloud and pay the monthly fee
    Or join the Photoshop Photography Program (US9.99/month) and get PS CC+LR

Maybe you are looking for