Referring to the value of previous years

Hello

I have a calculation where I refer to the previous value. Using the function @prior is the prior value within this year there. But it does not work for next year, that is, the Member is not get calculated for next year. So I wrote a rule like that. Please post if this is the right way to do it, or is there another way. My period dimension consists of 52 weeks, rolling up to months, that roll up to quarters, then half the year, then the year.

Mnpr_Available_L1_L2
(IF (@ISMBR (& CurrFiscalYr))
(@PRIOR ("Mnpr_Available_L1_L2") + @PRIOR ("Attr forced/Mov Out (see the Sub-)" ")) +"Go-Live ";
ELSE IF (@ISMBR (& NextFiscalYr) AND @ISMBR (Wk1))
(& CurrFiscalYr-> Wk52-> 'Mnpr_Available_L1_L2' + & CurrFiscalYr->-> Wk52 "Attr forced / Out Mov (see the Sub-) '") + "Go-Live";
ELSE IF (@ISMBR (& NextFiscalYr) AND NOT @ISMBR (Wk1))
(@PRIOR ("Mnpr_Available_L1_L2") + @PRIOR ("Attr forced/Mov Out (see the Sub-)" ")) +"Go-Live ";
ENDIF ;)

Kind regards
Brig.

I advise you to separate datacopy piece in another fix. Your script copy data unnecessarily 52 times.

FIXMnpr_Available_L1_L2)
DATACOPY & CurrFiscalYr-> Wk52 to & NextFiscalYr-> begbalance;
ENDFIX

DIFFICULTY (& CurrFiscalYr, "Attr forced/Mov Out (see the Sub-)" ")
DATACOPY & CurrFiscalYr-> Wk52 to & NextFiscalYr-> begbalance;
ENDFIX

I think that, after copying the balance opening balance, you can use straight @prior without any specific conditions on the first month.

See you soon,.
Alp

Tags: Business Intelligence

Similar Questions

  • Referring to the value of the element Page 0 in another page

    Apex: 4.2

    All,

    On my page 0, I gave 2 parts in stock. P0_QUESTIONS as a screen only and P0_OPTIONS like a Radio button.

    The source of these items are picked on the backend tables based on the: APP_PAGE_ID.

    All on Page 1: I chose an option in the account of radio

    If I want to see the value above in Page 3, how to do?

    As the elements are on Page 0, there is no point on P1 to designate...

    How can I go?

    TIA,

    J

    J wrote:

    I have ' developing a simple application of review.

    I have two tables,

    (1) QUESTIONS

    (2) OPTIONS

    Each page will have two elements. Question (screen only) and Options (Group of Radio buttons).

    For now, I have two P0_QUESTION and P0_OPTIONS points to the page0.

    The values for the above elements will be extracted from the database based on the APP_PAGE_ID.

    But to store the value of P0_OPTION on each page, I have to create a local element in each page.

    Since there will be a lot of questions, there will be a lot of pages and I wouldn't manually create local objects on each page, instead it is possible to create a component hidden dynamically based on the page no? Or something like a table to store the value?

    It is not practical to create an application with a separate page for each question. This type of application can be dynamically driven data using a question page. Rather than use the 0 page, create a unique question page containing the elements of the question and option (personally I would use relationships rather than objects, but that adds more complexity) and another to store the current number of the question. Before you navigate to the page in question for the first time, create three collections of the APEX. Two collections on queries for issues and the basic options and a third empty one to store the user's responses. On the page in question, back issues and options of the collections instead of the base tables. This ensures that users get consistent questions and options sets, even though they are simultaneously changed by other users. Terms of use on the current number of the question to control the display of the next/previous/Finish buttons or links; conditional calculations on next/previous controls to increment/decrement the current number of the question; a process to register the user in the collection's response; a conditional branch, triggered by control of finishing for a final presentation page; and an unconditional branch to the page in question to scroll through all the questions.

    (This is a good example of a Problem of XY. Rather than ask the question "I develop an application examination.» How can I implement this in APEX? "before you start, you selected an inappropriate solution and asked about the problems that have arisen in its application. You should always include some background to the question and if in doubt about the best approach, describe the requirements, not a proposed solution)

  • Tag editor to not remember the values introduced previously

    G ' Day

    If I type in < cffile > and then press CTRL-T, I get the popup tag editor dialog.  So I then enter the value for the FILE, before realizing that I have ACTION = "APPEND" selected, rather than the ACTION = "WRITE", so I click on WRITE, and the FILE attribute value is now empty.  Now, the value is a name long and tortuous variable or soemthing, so instead of having to type again, I flip to the append option  And the option FILE is empty, there also.  Frustrating.

    I think it would be better if the following two changes have been made:

    (1) with the same name attribute values are preserved between the different sets of attributes.  So if I fill in the FILE on the ACTION = "APPEND" attribute set, and I flip to ACTION = "WRITE", the FILE attribute value is it too crowded.

    (2) keep all attribute values where they are filled, so if one switches to and from the different attribute sets and back again, the previously entered values are always presented.  Should therefore take action to submit either attribute-game-specific, although I guess that.

    Thoughts?

    --

    Adam

    Hi Adam,.

    Yes, here is the good enhanacements to tag Wizard. Logged ER #82624.

    Thank you

    Valérie

    Adobe ColdFusion Builder Team

  • Referring to the value of a text field, not the legend

    How to refer to the value in a text field to make the data entered by the user "BOLD" / no fat without the caption of a field text in bold or not bold?

    Hello

    Two lines should do. The first turn the caption and the "BOLD" value, then the second changes the legend of back to normal:

    TextField1.font.weight = "bold";
    TextField1.caption.font.weight = "normal";
    

    Hope that helps,

    Niall

    Ensure the dynamics

  • Referring to the value of one procedure other

    I have a package in which a table is created each day of the week with date.then current that a second procedure is executed, which populates the table created in the first procedure with the data.

    the problem is that the second procedure is executed with no precise day, so how can I get the second procedure choose the table that was finally created by procedure 1, as if I call the procedure 2 1 procedure, then it will always give me the name of the table with today's date

    to explain better, lets say I want to run a procedure 2 today with tables created yesterday or the day before yesterday, how can I do

    I just want to take the table that was finally created by procedure 1.

    CREATE OR REPLACE PACKAGE CREATE_TABLE_WITH_SYSDATE

    CREATE_TABLE PROCEDURE;

    PROCEDURE INSERT_TABLE;

    END CREATE_TABLE_WITH_SYSDATE;

    CREATE OR REPLACE PACKAGE BODY CREATE_TABLE_WITH_SYSDATE

    CREATE_TABLE PROCEDURE IS

    V1_TEXT VARCHAR2 (10);

    V2_TEXT VARCHAR2 (10);

    V3_TEXT VARCHAR2 (10);

    V4_TEXT VARCHAR2 (100);

    BEGIN

    SELECT TO_CHAR (SYSDATE, 'MM') INTO V1_TEXT FROM DUAL;

    SELECT TO_CHAR (SYSDATE, 'DD') INTO V2_TEXT FROM DUAL;

    SELECT EXTRACT (YEAR SYSDATE) IN V3_TEXT FROM DUAL;

    V4_TEXT: = 'CREATE TABLE TEMP_ ' | V3_TEXT | V2_TEXT | V1_TEXT' (TEXT VARCHAR2 (10)';)

    IMMEDIATELY RUN V4_TEXT;

    END;

    END;

    PROCEDURE INSERT_TABLE IS

    V5_TEXT VARCHAR2 (100);

    BEGIN

    V5_TEXT: = 'INSERT'. V4_TEXT| "VALUES ('TEST')';

    IMMEDIATELY RUN V5_TEXT;

    COMMIT;

    END;

    END;

    END CREATE_TABLE_WITH_SYSDATE;

    What should be V4_TEXT| replaced in in the second procedure?

    Try the below.

    CREATE OR REPLACE PACKAGE create_table_with_sysdate

    Create_table PROCEDURE;

    PROCEDURE insert_table;

    END create_table_with_sysdate;

    /

    CREATE OR REPLACE PACKAGE BODY create_table_with_sysdate

    Create_table PROCEDURE IS

    v4_text VARCHAR2 (100);

    BEGIN

    v4_text: = 'CREATE THE TABLE TEMP_ ' | TO_CHAR (SYSDATE, 'YYYYDDMM'). ' (text VARCHAR2 (10))';

    EXECUTE IMMEDIATE v4_text;

    Create_table END;

    PROCEDURE insert_table IS

    v5_text VARCHAR2 (100);

    v_tablename user_objects.object_name%TYPE;

    v_cnt NUMBER;

    BEGIN

    SELECT COUNT (*) IN v_cnt

    From user_objects

    WHERE type_objet = 'TABLE '.

    AND TO_CHAR (created, ' YYYYDDMM ',' NLS_DATE_LANGUAGE = ENGLISH') = REPLACE (object_name, 'TEMP_');

    IF v_cnt > = 1 THEN

    Object_name SELECT INTO v_tablename

    FROM (SELECT object_name,

    ROW_NUMBER() over (ORDER BY created DESC) rn

    From user_objects

    WHERE type_objet = 'TABLE '.

    AND TO_CHAR (created, ' YYYYDDMM ',' NLS_DATE_LANGUAGE = ENGLISH') = REPLACE (object_name, 'TEMP_'))

    WHERE rn = 1;

    v5_text: = "INSERT INTO ' |" v_tablename | "VALUES ('TEST')';

    EXECUTE IMMEDIATE v5_text;

    END IF;

    COMMIT;

    END insert_table;

    END create_table_with_sysdate;

    /

  • compare the value of previous line with the current value

    I need to compare the previous value with the current value. All Oracle functions could there be to do?
    Something similar as a result.
    If previous (Amt {}) > Current (({Amt}) then 0 Else Null.)

    Something like that?

    SQL> WITH test_data AS
      2  (
      3          SELECT 107019 AS ID, 1583 AS AMT FROM DUAL UNION ALL
      4          SELECT 107019 AS ID, 1572 AS AMT FROM DUAL UNION ALL
      5          SELECT 107019 AS ID, 1572 AS AMT FROM DUAL
      6  )
      7  -- END SAMPLE DATA
      8  SELECT  ID
      9  ,       (CASE
     10                  WHEN LAG(AMT,1) OVER (PARTITION BY ID ORDER BY ID) = AMT THEN NULL
     11                  ELSE AMT
     12          END) AS AMT
     13  FROM test_data;
    
            ID        AMT
    ---------- ----------
        107019       1583
        107019       1572
        107019
    
  • How to extract the values of previous header?

    Hello


    loading a flat file, I have a table (simplified example) as follows


    Interface line Id Type value line Num
    1 1 4 header
    1 line 1 2
    1 2 3 line
    1 5 4 header
    1 line 19 5
    1 line 3 6
    1 7 7 header
    1 line 66 8
    1 33 9 header
    1 line 2 10


    Can anyone tell me with a single piece of SQL I'm looking for the record header for each line.

    for example, in my example

    Line 2, 3 = Header 4
    Line 5, 6 = header 5
    Line 8 = Header 7
    Line 10 = Header 33


    Thanks for your comments,


    Robert.

    It's pretty generic:

    in my query, replace the Tag with your real Table (I don't have the table!):

    SELECT Interface_Id,
           Row_type,
           num,
              'Header = '
           || (SELECT VALUE
               FROM    q1
               WHERE  q1.num = (SELECT MAX(num)
                                FROM    q2
                                WHERE  q2.num < q.num
                                AND    row_type = 'Header')) header
    FROM   
    WHERE  row_type = 'Line'
    
  • Referring to the value of a text input form

    I want to refer to a value in another form (on the same page). That typing for? to allow me to pass the user defined "SConsultant" to the DisplayRvw function when you press "DisplayButton?


    function DisplayRvw (ValueX)
    {
    Window.Open (" http://localhost:8300/CostPrediction/CARP/DisplayRvw.cfm?ID="+ValueX)
    }

    < name of the form = 'DataForm' id = 'DataForm' method = "get" >
    < td > < input type = "text" Name = "SConsultant" Value = "6" id = "SConsultant" > < table >
    < / make >

    -cfform named "MainForm".

    < cfinput type = "button" name = "DisplayButton.
    value = "Journal of the society.
    onclick = "DisplayRvw('#???) #')" />

    onclick = "DisplayRvw (document.getElementById('SConsultant').value); »

  • JavaScript - referring to the value of the report column

    Hello

    In my application, I have a 'Test' relationship with some columns. In the "PFT_PCODE" column values can be 1 or 2.
    What I want is to display report in red table cell, if the "PFT_PCODE" value is 1, or table at orange cell, if the "PFT_PCODE" value is 2, respectively.

    I tried to do something in Javascript, based on the example of a Vikas. I put in the

    Header of the region:

    < style type = "text/css" >
    {.rot}
    background-color: red;
    }
    .Orange {}
    background-color: orange;
    }
    < / style >


    Footer area:

    < script type = "text/javascript" >
    var spans = document.getElementsByTagName ('span');
    for (var j = 0; j < spans.length; j ++) {}
    If (spans [j] .className == 'farbe') {}
    var td is html_CascadeUpTill (spans [j], 'TD');.
    If (document.getElementsById('#PFT_PCODE#').value == 1) {}
    td.className = "rot";
    }
    else {}
    td.className = 'orange ';
    }
    }
    }
    < /script >

    The "PFT_PCODE" column is marked as "farbe" CSS class

    Unfortunately it does not work, I do not know if I have the right to report to reference the column value. Since I'm a newbie in Javascript, I'd be happy to help.

    I put my request (reduced) on apex.oracle.com for the test.
    Workspace: app
    Login: [email protected]
    PW: riponi

    Thanks in advance,

    Roger

    Hello

    OK - the problem is that some of your columns had tables in the cells and it was upsetting the javascript!

    I have changed the script:

    <script language="JavaScript" type="text/javascript">
    <!--
    
    function hilite(f1)
    {
     var h = document.getElementById(f1);
     var t = h.parentNode;
     while (t.tagName != 'TABLE')
     {
      t = t.parentNode;
     }
     var rows = t.rows;
     var k;
     var j;
     var c;
     var headers = t.getElementsByTagName("TH");
     for (k = 0; k < headers.length; k++)
     {
      if (headers[k].id == f1)
      {
        c = k;
      }
     }
     for (k = 1; k < rows.length; k++)
     {
      j = rows[k].cells[c];
      if (j.innerHTML == '2')
      {
        j.style.backgroundColor = 'purple';
        j.style.color = 'yellow';
      }
      if (j.innerHTML == '1')
      {
        j.style.backgroundColor = 'red';
        j.style.color = 'white';
      }
     }
    }
    
    //-->
    </script>
    

    and it seems to be ok

    Andy

  • Value of the previous year

    I try to get a value from the month last year:

    for example
    AFA 08 Dec 200
    Exercise Jan 09 250

    To get a total for the 2 months that I tried to put the value of Dec in a variable:

    FIX (@MEMBER (@PREVSIBLING (@CURRMBR (FinancialYear)))
    {LyValue} = "Dec".
    ENDFIX

    but it becomes an error.

    It works:

    FIX (@MEMBER (@PREVSIBLING ("FY09")))
    {LyValue} = "Dec".
    ENDFIX

    Any ideas on how to get a dynamic selection of the year when I use several years? Of course, I don't want to hardcode the years.

    With the keys V 11.1.1.3

    Thank you.

    I hope that answers your needs.

    IF (@ismbr (Jan))
    'Spend Accum' = +@mdshift 'spend' ("Accum spend",-1,, 11,,);
    on the other
    'Spend Accum' = +@prior 'spend' ("spend Accum");
    endif;

  • How to complete the data or details of the only this year and the previous year for the given RATNG?

    Hi all

    I created a form with 5 blocks (namely ENQACMHDR, ENQACMDTL, ENQACEHDR, ENQACEDTL, ENQACSPEC), where I have 8 push buttons (namely ENTER_QUERY, EXEC_QUERY, CLEAR, FIRST, NEXT, PREVIOUS, LAST, and EXIT).

    This form is created just for display purposes only. So after that I ran, all blocks have been blocked against insert and update.

    I have question on 2 fields 'ENQNO' and "RATNG" (both belong to the ENQACMDTL block).

    When I click on "EXEC_QUERY" directly, all data for all years fills.

    But the user wanted the data to be populated only this year and the previous year.

    Yes, on ' Clause WHERE' of the property_palette of the 'ENQACMDTL' block , I put in the following condition:

    SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYY') OR SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (SYSDATE, 'YYYY')

    PROPERTY PALETTE (ENQACMDTL block)
    WHERE ClauseSUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYY') OR SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (SYSDATE, 'YYYY')


    Data only this year and the year before are now filled. Its ok with the field of "ENQNO".

    The problem is when I have queries on the field "RATNG. 'RATNG' is a Text_item with number of displayed items = 5. (5 lines)


    Here are the 2 columns in a Table (name = ENQACMDTL) in the database.


    ENQNO RATNG
    2013900054500KC2
    2013900047800KC4
    2013520018750KC6
    ...............
    20129000371000KC2
    2012520109500KC2
    2012140019750KC6
    ..................
    2011540036500KC2
    20111000301000KC2
    ..................
    .................
    200610000790KD8
    2006750014750KC6
    2006900072500KC2

    The first 4 issues of "ENQNO" represents the year. There is more than a lakhs of records.

    So, when I have queries on the field "RATNG."

    Example: for RATNG = 500KC2;

    I click on ENTER_QUERY, the field of "RATNG", I put in the 500KC2 of the value and click on EXEC_QUERY; Details regarding the 500KC2 is displayed as well as all the other junk RATNG as 750KC6, 1000KC2 (which belongs to the ENQNO of the current year and previous year) also gets displayed.

    I want details of only RATNG (500KC2) to display, but only for the current year and the previous year, it is 2013900054, 2012520109 (ENQNO).

    Other than 500KC2 RATNG, no other RATNG must be displayed.

    500KC2 = RATNG is also present for ENQNO = 2011540036, 2006900072. But I don't want them to view.

    I want only the data or details of the current year and the previous year to be filled or displayed for the given RATNG.

    Can you help me or tell me what I do for this?

    Hope I'm clear with my question!

    If my question is not clear, let me know please.

    Thank you.

    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

    Oracle forms 6i.

    1. check null values in the enqacmdtl.enqno, if so treat them properly.

    2. check the result of select to_char (add_months (sysdate,-12), 'YYYY') prev_year curr_year of double to_char(sysdate,'YYYY')

    3. change the place where clause "year" in the value of numAriques.

    where to_number (substr (enqacmdtl.enqno, 1, 4)) > = to_number (to_char (add_months (sysdate,-12), 'YYYY'))

    Then let me know the result.

  • With the help of SQL, need to display the previous year, current year and the year next to single variable

    Hi all

    We have an obligation to state the previous year, current year and values of the year next as a LOV in the ADF page.

    This is the query that retrieves the previous year, current year and next year. But the result of this query displays values in 3 columns:

    Select (Extract(year from sysdate)-1), extract (year sysdate), (extract (year sysdate) + 1) twice;

    Output:

    2012 2013 2014


    But I want to display them in a single with 3 rows as column:

    2012

    2013

    2014


    Please your ideas.

    or in the same way

    SELECT EXTRACT (YEAR FROM ADD_MONTHS (SYSDATE, 12 *(LEVEL-2)))

    OF the double

    connect by level<>

  • SQL to get % increase in the amount of the previous year

    Version 11g

    Hello

    I have a requirement where I need to calculate the percent increase of wages and costs compared to the previous year,

    If the output should be something like
    Year        Salary       %increase                Rent         %Increase
    
    2012       1000          1000%                   100                     1000%
    2011       100             100%                    10                      100%(depending on last year value)
    2010    . . . 
    .
    .
    .
    The inclusion of scripts are
    create table sal
    (exp_type   varchar2(100),
    exp_date  date,
    exp_amt number);
    
    
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-JUN-11','DD-MON-RR'),685);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-JUN-11','DD-MON-RR'),84.89);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-JUL-11','DD-MON-RR'),685);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-JUL-11','DD-MON-RR'),84.89);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-AUG-11','DD-MON-RR'),687);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-AUG-11','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-SEP-11','DD-MON-RR'),687);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-SEP-11','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-OCT-11','DD-MON-RR'),750);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-OCT-11','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-NOV-11','DD-MON-RR'),750);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-NOV-11','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-DEC-11','DD-MON-RR'),755);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-DEC-11','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-JAN-12','DD-MON-RR'),755);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-JAN-12','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-FEB-12','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-FEB-12','DD-MON-RR'),750);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-MAR-12','DD-MON-RR'),766);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-MAR-12','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-JUN-12','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-JUN-12','DD-MON-RR'),740);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('02-JUL-12','DD-MON-RR'),735);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('02-JUL-12','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-AUG-12','DD-MON-RR'),739);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-AUG-12','DD-MON-RR'),93.4);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('02-SEP-12','DD-MON-RR'),740);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('02-SEP-12','DD-MON-RR'),93.4);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-APR-12','DD-MON-RR'),570);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-APR-12','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-MAY-12','DD-MON-RR'),740);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-MAY-12','DD-MON-RR'),89.04);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-NOV-12','DD-MON-RR'),845);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-NOV-12','DD-MON-RR'),93.4);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-OCT-12','DD-MON-RR'),900);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-OCT-12','DD-MON-RR'),93.4);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-FEB-10','DD-MON-RR'),508);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-FEB-10','DD-MON-RR'),84.89);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('03-MAR-10','DD-MON-RR'),84.89);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('03-MAR-10','DD-MON-RR'),500);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-APR-10','DD-MON-RR'),509);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('04-APR-10','DD-MON-RR'),84.89);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-MAY-10','DD-MON-RR'),84.89);
    Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-MAY-10','DD-MON-RR'),514.46);
    Any suggestions on how we can calculate the increase in % at run time?


    Thank you
    Ryan

    Hello

    ryansun wrote:
    Thank you Al, Frank!

    I am struggling with the math a bit part. Or maybe % increase is not the correct term. So what I want is the increase in rent and wages in terms of % over the previous year. Thus, for example the output below.

    The salary in 2012 is 8280
    The salary in 2011 is 4999

    so 8280-4999 = 3281

    3281 is 65.6% of 4999.

    The increase last year was 65.6% compared to the last years value while the output of two sqls 165,6%

    Right, Al and I assumed you wanted the percent of last year, not the percentages of increase... Subtract 100 if you want the percentage increase.

  • Find the stock quantity of the previous year with another way...

    Hello
    I have a table with the following structure:
    create table stock_qties_items
    (subinv varchar2(10),item_code varchar2(10),period_name varchar2(5), qty_a number(5,2), qty_b number(5,2));
    alter table stock_qties_items
    add constraint stock_qties_items_pk primary key(subinv,item_code,period_name);
    and some data...
    insert into stock_qties_items
    values('01','410010010','01-08',10.50,0);
    insert into stock_qties_items
    values('01','410010010','02-08',19.30,10.35);
    insert into stock_qties_items
    values('01','410010010','03-08',3,0);
    insert into stock_qties_items
    values('02','410010010','03-08',8.54,1.90);
    insert into stock_qties_items
    values('03','410010010','03-08',120.45,1.25);
    insert into stock_qties_items
    values('03','410010010','04-08',502.10,6.50);
    insert into stock_qties_items
    values('03','410010010','05-08',5.05,6.20);
    insert into stock_qties_items
    values('03','410010010','08-08',19.35,65.90);
    insert into stock_qties_items
    values('02','410010010','10-08',40.85,5.20);
    insert into stock_qties_items
    values('03','410010010','12-08',75.20,90.15);
    insert into stock_qties_items
    values('02','410010020','12-08',60.55,0.85);
    insert into stock_qties_items
    values('01','410010020','07-08',100.90,10.05);
    insert into stock_qties_items
    values('01','410010010','01-09',8.95,0.05);
    insert into stock_qties_items
    values('02','410010010','01-09',88.95,100.05);
    insert into stock_qties_items
    values('03','410010020','01-09',91.05,0.05);
    insert into stock_qties_items
    values('04','410010020','01-09',11.75,10.05);
    insert into stock_qties_items
    values('04','410010010','03-09',1.75,110.40);
    insert into stock_qties_items
    values('04','410010010','05-09',0.75,10.40);
    insert into stock_qties_items
    values('04','410010025','03-09',1.75,90.00);
    insert into stock_qties_items
    values('04','410010025','07-09',51.75,190.00);
    insert into stock_qties_items
    values('04','410010010','09-09',62.15,10.05);
    insert into stock_qties_items
    values('04','410010010','10-09',39.15,0);
    The goal is to find the stock for the current year and previous year. I have accomplished with the following...
    select period_year,
               item_code,
               sqi1 stock_prev_year,
               sum(stock_curr_year) stock_curr_year
        from
        (
        select  to_char(to_date(substr(period_name,4,2),'RRRR'),'RRRR') period_year,
             item_code,
          (select sum(qty_a+qty_b)
                  from stock_qties_items sq
                  where sq.item_code=sqi.item_code
                 and to_char(to_date(to_number(substr(sqi.period_name,4,2)-1),'RRRR'),'RRRR')=
                        to_char(to_date(substr(sq.period_name,4,2),'RRRR'),'RRRR')
             ) sqi1,
             qty_a+qty_b stock_curr_year
         from stock_qties_items sqi
         )
         group by period_year,
               item_code,
               sqi1
    which generates the following output...
    PERIOD_YEAR ITEM_CODE  STOCK_PREV_YEAR STOCK_CURR_YEAR
    ----------- ---------- --------------- ---------------
    2008        410010020                           172,35
    2009        410010010           991,79          432,65
    2008        410010010                           991,79
    2009        410010025                            333,5
    2009        410010020           172,35           112,9
    Y at - it another way to achieve the same result, given that this table has a few million records and in this request a few other tables parameter should be added...?

    Note: I use Db 10 g v.2
    Thank you
    SIM

    Using the LAG function:

    SQL> with t as (
      2  select to_char(to_date(substr(period_name,4,2),'RRRR'),'RRRR') period_year,
      3  ITEM_CODE, sum(qty_a+qty_b) STOCK
      4  from stock_qties_items
      5  group by to_char(to_date(substr(period_name,4,2),'RRRR'),'RRRR'), ITEM_CODE
      6  )
      7  select period_year, ITEM_CODE,
      8  lag(stock) over (partition by ITEM_CODE order by period_year) stock_prev_year,
      9  stock stock_curr_year
     10  from t
     11  order by item_code, period_year;
    
    PERI ITEM_CODE  STOCK_PREV_YEAR STOCK_CURR_YEAR
    ---- ---------- --------------- ---------------
    2008 410010010                           991,79
    2009 410010010           991,79          432,65
    2008 410010020                           172,35
    2009 410010020           172,35           112,9
    2009 410010025                            333,5
    

    Max
    [My Italian oracle Blog | http://oracleitalia.wordpress.com/2010/01/30/compilazione-condizionale-in-plsql/]

  • incremensum under condition (condition is the value of the sum of the previous line)

    Hello
    I know that is a little tricky but I need to know the credit of a client after each invoice.
    so if sum(invoice_val-previous_credit) > 0, then the credit is 0 credit else is previous_credit-invoice_val.
    As you can see to dermine the credit value of the current row, it is necessary to check the value of the previous row. Is it possible to somehow?

    E.G.
    If the situation in the table is the following:
    ID_CLIENT     ID_invoice     invoice_VAL
    8.789     220.227     120,47
    8.789     238.342     109,76
    8.789     246.388     121,69
    8.789     258.163     137,45
    8.789     268.969     138,67
    8.789     295.455     145,16
    8.789     311.395     138,92
    8.789     327.104     138,96
    8.789     340.793     -335,18
    8.789     375.451     129,14
    8.789     386.650     125,57
    8.789     398.606     124,18
    8.789     428.166     31,66
    8.789     435.844     25,93
    8.789     447.639     34,32
    8.789     462.137     -43,64
    8.789     475.613     -110,39
    8.789     485.022     92,29
    8.789     495.807     91,67
    I need something like this:
    ID_CLIENT     ID_invoice     invoice_VAL credit
    8.789     220.227     120,47     0,00
    8.789     238.342     109,76     0,00
    8.789     246.388     121,69     0,00
    8.789     258.163     137,45     0,00
    8.789     268.969     138,67     0,00
    8.789     295.455     145,16     0,00
    8.789     311.395     138,92     0,00
    8.789     327.104     138,96     0,00
    8.789     340.793     -335,18     335,18
    8.789     375.451     129,14     206,04
    8.789     386.650     125,57     80,47
    8.789     398.606     124,18     0,00
    8.789     428.166     31,66     0,00
    8.789     435.844     25,93     0,00
    8.789     447.639     34,32     0,00
    8.789     462.137     -43,64     43,64
    8.789     475.613     -110,39     154,03
    8.789     485.022     92,29     61,74
    8.789     495.807     91,67     0,00
    Thank you very much

    Published by: 4ndr34 on January 28, 2010 13:38

    Hello

    4ndr34 wrote:
    Thanks, but the model is not available in oracle9 :(

    Are - that you mentioned before?
    It's a good idea to include your version number whenever you ask a question, especially if the version is as old as Oracle 9.

    Here's an analytical solution that must work at Oracle 9 (and more):

    WITH     e     AS
    (
         SELECT     hiredate
         ,     CASE
                   WHEN  job     IN ('PRESIDENT', 'SALESMAN')
                   THEN  -sal
                   ELSE  sal
              END     AS sal2
         ,     ROW_NUMBER () OVER ( ORDER BY  hiredate
                                   ,            empno
                           ) AS rnum
         FROM     scott.emp
    )
    ,     got_grp_start     AS
    (
         SELECT     h.*
         ,     CASE
                   WHEN  sal2 >= 0
                   THEN  0
                   WHEN  EXISTS ( SELECT    NULL
                                     FROM      e   l
                               JOIN      e   m     ON     m.rnum     >= l.rnum
                               WHERE     l.rnum     < h.rnum + 0     -- See note below
                               AND      m.rnum     < h.rnum + 0     -- See note below
                               GROUP BY      l.rnum
                               HAVING      SUM (m.sal2) < 0
                             )
                   THEN  0
                   ELSE  1
              END          AS grp_start
         FROM     e     h
    )
    ,     got_grp          AS
    (
         SELECT     got_grp_start.*
         ,     SUM (grp_start) OVER (ORDER BY rnum)     AS grp
         FROM     got_grp_start
    )
    SELECT     hiredate
    ,     sal2
    ,     GREATEST ( SUM (-sal2) OVER ( PARTITION BY  grp
                                            ORDER BY         rnum
                            )
               , 0
               )     AS credit
    FROM     got_grp
    ORDER BY     rnum
    ;
    

    The EXISTS subquery in got_grp_start does not work (at least in Oracle 10.2.0.3.0 or 11.1.0.6.0) if it refers to "h.rnum", but it does if it refers to "h.rnum + 0" or "h.rnum - 0". ".

    The sole purpose of subquery e is to produce a useful set of raw data, including a simple expression (rnum) that can be used in sorting. You probably have something like e, according to your actual table.

    If you need a separate calculation for, say, all the departments, and then add PARTITION BY analytical clauses.

Maybe you are looking for

  • How to get the text related to typedef diagram/comments?

    Greetings, Someone has an idea diagram-text editable via a typedef - so that the the typedef update changes the visible text by programmers? I tried to use a string with a value of text by default, but it does work well for me.  With string-typedef,

  • How do I know what hardware I have in my dv4t?

    I have a Pavilion dv4t-4100 and the hard drive crashed. I installed a new hard drive and the OS, but I don't know what drivers I need to download for my network adapter, and other hardware components where there are several choices of drivers and com

  • Can't open the images in Windows Live Photo Gallery

    I had windows live photos with all my photos for some reason, I can't open it and receive an error code. tried HP for help, but they do not solve the problem I open the photo gallery simple but really like the format of the live Photo Gallery windows

  • print a 6 "x 9" with C7250

    I have a Windows 7 32-bit desktop operating system and HP C7250.  I am trying to print the cards 6 x 9 inches and the printer refuses to do.  I created the design custom in my word 2013 and tried custom settings of the printer and the printer refuses

  • No message ink level for printer Epson DX67450 after updating to Windows 8

    Original title: Mr Paul Holifield My old computer Widows Vista had a printer control utility that allowed me to check the ink levels, clean the nozzles and other things on my Epson DX67450 printer. I am now running Windows 8 and I do not get the ink