Table expanding: calculation of the difference in the value of the previous row

Hello

I'm a complete newbie to LiveCycle Designer (ES2) and created under the document with a table in full expansion.

Shared files - Acrobat.com

My goal is to make the friendly form by adding a calculation in the field "Twist" that calculates the difference of the current line to the previous row.

I have no idea about Java Script, I'm afraid and also do not know if this is possible at all, so it's probably a bad idea after all.

The reason for setting up as a table expansion is so that the form can be used for all 32 instances form would be used for (they all need different number of rows in total).

The calculation will start in row 2 (Checklist.Table1), take the value of the entry in row 2 torsion and calculate the difference in the value of the twist entry in row 1.

Then, in row 3, it calculates the difference between the value of the twist in the row 3 tier 2, etc.

So subtract the value of the field in then with the value line onlinen-1 or something in that sense.

Is there anyone at all who could help me with that at all?

I would be very grateful for any advice you could give me.

Thank you very much!

Mathilda

Hi Matilda,.

Try this code;

if (Row1.index > 0 && !Row1.resolveNode("NumericField4[0]").isNull)

 var prevTwist = Table1.resolveNode("Row1[" + (Row1.index - 1) + "].NumericField4[0]").rawValue

 var result = Math.abs(3000 / (Row1.resolveNode("NumericField4[0]").rawValue - prevTwist));

 this.rawValue = result;

 this.rawValue = "";

Concerning

Bruce

Tags: Adobe LiveCycle

Similar Questions

  • By subtracting the previous row less the current line in SQL

    I have a table - orders.

    How to subtract the previous row less line current for incoming column

    enter image description here

    If anyone can help.

    Hello

    It is not clear what you want. What is the previous row? What order to examine DATE_IN?

    Here is an example of using the function DATE_IN LAG to retrieve the previous value of the line consider the sort column.

    WITH commands LIKE (select to_date (27 May 2015 ', ' dd/mm/yyyy') date_in, 83 of the double incoming_vol)

    Union of all the

    Select to_date (May 26, 2015 ', ' dd/mm/yyyy') date_in, 107 double incoming_vol

    Union of all the

    Select to_date (May 25, 2015 ', ' dd/mm/yyyy') date_in, 20 incoming_vol of the double

    Union of all the

    Select to_date (May 24, 2015 ', ' dd/mm/yyyy') date_in, 7 incoming_vol of the double

    Union of all the

    Select to_date (May 22, 2015 ', ' dd/mm/yyyy') date_in, 71 double incoming_vol

    )

    SELECT date_in

    incoming_vol,

    NVL (lag (incoming_vol) (date_in release order), 0)-incoming_vol previous_row_minus_current_row

    Orders

    ORDER BY 1 desc;

    DATE_IN INCOMING_VOL PREVIOUS_ROW_MINUS_CURRENT_ROW

    ----------- ------------ ------------------------------

    27/05/2015 83 24

    26/05/2015-107-87

    25/05/2015-20-13

    24/05/2015             7                             64

    22/05/2015-71-71

    If this isn't what you want then please give the expected results.

  • How to get the sum of the first row in the previous row?

    Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line. Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?

    Hello

    kamranpathan wrote:
    Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line.

    If you do not explicitly give a windowing clause, then you get the default windowing clause you indicated.
    If you want another clause of windowing, ionclude in the analytic function call.

    Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?

    Yes. The correct syntax for "Previous rank" is «PREVIOUS 1»

    ...  ROWS BETWEEN  UNBOUNDED PRECEDING
                AND        1          PRECEDING
    

    For more information, search for "Analytic Functions" in the manual of the SQL language:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions004.htm#sthref917

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.
    You will find the answers better faster if you always provide this information whenever you post a question.

    Published by: Frank Kulash, Sep 17, 2011 17:04
    I just saw Etbin responses.
    As usual, Etbin has a good point. If the column that you are basically cannot be NULL, then it is probably easier to subtract the total current line and use the default windowing clause.
    Even if it can be null, you find may be easier to use this approach.

  • Sum of the values of the previous rows in a PivotTable

    Hello

    I have a dynamic table has several lines (dynamically added via a button).  A column in the table is a quantity column.  Another is a Total of the column.  We do not keep a cumulative, but wants to only display an total when the rest of the cells in the same row are emty and the previous lines has / have values in the quantity column.  The Total is the sum on the Quatnities until a blank line.  Here is a sample.  How can I get the value of the quantities in the previous lines?

    Quantity Total


    5
    8
    12

    25


    7
    27

    34


    22

    22


    Another option could be to put the Total in the last row with data as opposed to the line below the data.

    Any ideas?

    Kind regards

    Karl

    The script is written to achieve your requirement (i.e. the second approach you mentioned)

    .

    You can either contact me at [email protected] for the example of created form.

    Or what follows is the Source XML of the form. Copy all the content in your form XML source mode and see the result.

    http://ns.Adobe.com/XDP/"timeStamp =" "2012-02 - 28 T 14: 04:54Z ' uuid ="2c561cdf-3377-4e84-9a89-51e740bb2fea">"

    Adding line

    Quantity

    Total

    user interface

    >

    character = "Myriad Pro

    "/>

    margin = topInset ' 1 mm ' bottomInset = ' 1 mm ' leftInset = ' 1 mm ' rightInset = ' 1 mm»

    "/>

    para vAlign = "middle".

    "/>

    border

    >

    edge

    />

    angle thickness = "0,1778 mm

    "/>

    border

    >

    field

    >

    = "Total" field name "44.47 mm" h = w = "9,317 mm" access = "readOnly".

    ">

    user interface

    >

    numericEdit

    >

    presence at the border = "hidden".

    ">

    border

    >

    the margin of

    />

    numericEdit

    >

    user interface

    >

    character = "Myriad Pro

    "/>

    margin = topInset ' 1 mm ' bottomInset = ' 1 mm ' leftInset = ' 1 mm ' rightInset = ' 1 mm»

    "/>

    this.rawValue = null; Clear the total value

    }

    } catch (e)

    {

    app.alert (e)

    }

    9.0.0.0.20091029.1.612548.606130

    http://www.XFA.org/schema/XCI/2.8/">

    PDF

    1.7

    3

    *

    http://www.XFA.org/schema/XFA-locale-set/2.7/">

    January

    February

    March

    April

    May

    June

    July

    August

    September

    October

    November

    December

    Jan

    Feb

    Mar

    Apr

    May

    Jun

    Jul

    Aug

    Ms

    Oct

    Nov

    Dec

    Sunday

    Monday

    Tuesday

    Wednesday

    Thursday

    Friday

    Saturday

    Sun

    LUN

    Mar

    Fri

    Game

    Fri

    Sam

    AM

    PM

    BRITISH COLUMBIA

    AD

    EEEE, MMMM D, YYYY

    MMMM D, YYYY

    MMM D, YYYY

    M/D/YY

    SS Z

    SS Z

    SS HAS

    h: mm A

    GyMdkHmsSEDFwWahKzZ

    z, zz9.zzz

    $z, zz9.99 | ($z, zz9.99)

    z, zz9%

    .

    ,

    %

    -

    0

    $

    USD

    .

    "RDF: RDF xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#

    ">

    "RDF: description xmlns:xmp ="http://ns.adobe.com/xap/1.0/"rdf: subject"

    ="">

    XMP:MetadataDate > 2012-02-28 T 14: 04:54Z

    >

    XMP:CreatorTool > Adobe LiveCycle Designer ARE 9.0

    >

    RDF: description

    >

    "RDF: description = xmlns:pdf"http://ns.adobe.com/pdf/1.3/"rdf: subject"

    ="">

    PDF:producer > Adobe LiveCycle Designer ARE 9.0

    >

    RDF: description

    >

    "RDF: description = xmlns:xmpMM"http://ns.adobe.com/xap/1.0/mm/"rdf: subject"

    ="">

    xmpMM:DocumentID > uuid:2c561cdf-3377-4e84-9a89-51e740bb2fea

    >

    RDF: description

    >

    "RDF: description = xmlns:desc"http://ns.adobe.com/xfa/promoted-desc/"rdf: subject"

    ="">

    DESC:version rdf:parseType = "resource".

    ">

    RDF: value > 9.0.0.0.20091029.1.612548.606130

    >

    DESC:REF > / template/subform [1]

    >

    DESC:version

    >

    RDF: description

    >

    RDF: RDF

    >

    x: xmpmeta >

  • Hide a field value based on the value of the previous row

    I need to read the string before the underscore (_) and show that the value in the 1st row for the field of Value1. For example, if the previous string (ABCDE) is equal to that of the second line I need to hide the value (100) on the field of the value1.

    Sample data:

    Report IDVal1Val2Val3
    ABCDE_01100200300
    ABCDE_02100250350
    XYZ5006028

    Final results:

    Report IDValue1Value2Value3
    ABCDE_01100200300
    ABCDE_02250350
    XYZ5006028

    I am using code below but error.

    <? If: xdoxslt:get_variable($_XDOCTX,_'x')! = substr (REPORT_ID, 0, instr(REPORT_ID, '_', 0) - 1)? >

    <? Value1? >

    <? end if? >

    <? xdoxslt:set_variable ($_XDOCTX, 'x', substr (REPORT_ID, 0, (instr(REPORT_ID, '_', 0)-1)))? >

    You can use this condition instead:

    It will manage both of your cases.

  • Customize the table (first column and the first row)

    Hello everyone, I have a question: How can I insert words and numbers in the same table?

    I have create a VI that measure the temperature with an external instrument and put the data into a table, which is saved.

    Each line is a Thermocouple and each column is a measure, but there are only numbers!
    I would have the first column with the name of the channel and line of fist with the name of the measure.

    I had create an excel for example to explain my wish (Cattura.PNG).

    Thanks to all who help me

    You can insert headers required as column and row to convert it to an array of strings, as in the image below.

  • Table of contents of the previous project import

    I hope someone can help me. I came across some problems with a robohelp project (well Yes, played and run the project on a network and lost) but to make a long story short, I got an old backup of the project I had on my computer and then imported all the headings of the broken Server version and I'm especially back in business.

    The only thing I have however is the most recent TOC and Index files. I tried just copy and paste the recovered files .hhc and .hhk project folder broken to the project folder but when I'm in Robohelp I still don't see the table of contents options?

    What can I do?

    Hello

    What version of RoboHelp do you use? If it's a fairly recent version, it should be pretty easy to get the table of contents added. For example, in RoboHelp 11, you are able to right click on the folder TOC in project manager and choose "New Table of contents". Then you can give it a name, click the icon selection and point to one of the TOCs your copied on. That action could import the structure in a table of contents would be aware of.

    See you soon... Rick

  • Need help to write the query to extract the value of the previous row - Lag not help


    Hello

    I created follwing table.

    Create table test

    (number of fi,

    number of fo_fv

    number of jup_fv

    action varchar2 (10)

    );

    insert into TEST(1,1,1,'LOAD');

    Insert into TEST (2, NULL, 2, "ROLL");

    insert into TEST(3,,3,'ROLL');

    insert into TEST(4,,4,ROLL);

    insert into TEST (5,2,5,LOAD);

    I want the result of the query as below:

    FI FO_FV JUP_FV ACTION

    -------------------------------------------------------------------

    1          1                    1                    LOAD

    2          1                    2                    ROLL

    3          1                    3                    ROLL

    4          1                    4                    ROLL

    5          2                    5                    LOAD

    Help, please.

    Thank you!

    SQL > select fi
    2, max (fo_fv) on fo_fv (fi control)
    3, jup_fv
    4, action
    5 of the test;

    FI FO_FV JUP_FV ACTION
    ---------- ---------- ---------- ----------
    1 1 1 LOAD
    ROLL OF 2 1 2
    3 1 3 ROLL
    4 1 4 ROLL
    5 2 5 LOAD

    OR

    SQL > select *.
    2 test
    model 3
    Dimension 4 by (fi)
    5 measures (fo_fv, jup_fv, action)
    6 rules
    7   (
    8 fo_fv [any] = case when fo_fv [cv ()] is null
    9. can fo_fv [cv () - 1]
    10 fo_fv [cv () else]
    11 end
    (12);

    FI FO_FV JUP_FV ACTION
    ---------- ---------- ---------- ----------
    1 1 1 LOAD
    ROLL OF 2 1 2
    3 1 3 ROLL
    4 1 4 ROLL
    5 2 5 LOAD

  • date of breach varies at continuous intervals and ending date of the previous row

    Hello
    can someone give me an idea for situation below

    I have a table with records
    CREATE  TABLE test1
      (
        key VARCHAR2(11 BYTE) NOT NULL ENABLE,
       cd VARCHAR2(10 BYTE) NOT NULL ENABLE,
            start_dt DATE NOT NULL ENABLE,
        end_dt date,
        CONSTRAINT x1 PRIMARY KEY (key, cd, start_dt));
        
    Insert into test1 (key,cd,start_dt,end_dt) values ('1234','A',to_date('01-MAR-78 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('31-DEC-99 00:00:00','DD-MON-RR hh24:mi:ss'));
    Insert into test1 (key,cd,start_dt,end_dt) values ('1234','B',to_date('01-MAR-78 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('31-DEC-99 00:00:00','DD-MON-RR hh24:mi:ss'));
    Insert into test1 (key,cd,start_dt,end_dt) values ('1234','Q',to_date('01-JAN-89 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('31-JAN-97 00:00:00','DD-MON-RR hh24:mi:ss'));
    Insert into test1 (key,cd,start_dt,end_dt) values ('1234','B',to_date('01-FEB-97 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('30-APR-97 00:00:00','DD-MON-RR hh24:mi:ss'));
    insert into test1(key,cd,start_dt,end_dt) values ('1234','Q',to_date('01-FEB-97 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('30-APR-97 00:00:00','DD-MON-RR hh24:mi:ss'));
    Insert into test1 (key,cd,start_dt,end_dt) values ('1234','B',to_date('01-MAY-97 00:00:00','DD-MON-RR hh24:mi:ss'),to_date('31-MAR-99 00:00:00','DD-MON-RR hh24:mi:ss'));
    commit;
    
    key     cd     start_dt                     END_DT
    1234     B     01-MAR-78 00:00:00     31-DEC-99 00:00:00
    1234     A     01-MAR-78 00:00:00     31-DEC-99 00:00:00
    1234     Q     01-JAN-89 00:00:00     31-JAN-97 00:00:00
    1234     Q     01-FEB-97 00:00:00     30-APR-97 00:00:00
    1234     B     01-FEB-97 00:00:00     30-APR-97 00:00:00
    1234     B     01-MAY-97 00:00:00     31-MAR-99 00:00:00
    I want to merge the range date lines that overlap, break at intervals and set the indicator (A_IND, B_IND, Q_IND) accordingly. (IE, if a record in the source has a value for the 'cd' = 'B' column in a given date range, then the output should display 'Y' for the B_IND column for the date ranges in the source folder.)
    I want also to the date of the end of each record to be 1 day less than the start_dt of the next record, as shown below.
    and the output should be
    key     start_dt                          END_DT     A_IND     B_IND     Q_IND
    1234     01-MAR-78 00:00:00     31-DEC-88 00:00:00     Y     Y     N
    1234     01-JAN-89 00:00:00     30-JAN-97 00:00:00     Y     Y     Y
    1234     31-JAN-97 00:00:00     31-JAN-97 00:00:00     Y     Y     N
    1234     01-FEB-97 00:00:00     29-APR-97 00:00:00     Y     Y     Y
    1234     30-APR-97 00:00:00     30-APR-97 00:00:00     Y     Y     N
    1234     01-MAY-97 00:00:00     30-MAR-99 00:00:00     Y     Y     N
    1234     31-MAR-99 00:00:00     31-DEC-99 00:00:00     Y     Y     N

    Hello

    user12997203 wrote:
    Hello
    can someone give me an idea for situation below

    I have a table with records

    CREATE  TABLE test1 ...
    

    Thanks for the display of the data of the sample; It is very useful.

    I want to merge the range date lines that overlap, break at intervals and set the indicator (A_IND, B_IND, Q_IND) accordingly. (IE, if a record in the source has a value for the 'cd' = 'B' column in a given date range, then the output should display 'Y' for the B_IND column for the date ranges in the source folder.)

    Do not assume that everyone who wants to help you is familiar with your application and your needs. Explain what key role plays in this problem. See {message identifier: = 10865697}.
    Here's one way:

    WITH     change_points       AS
    (
         SELECT     key
         ,     start_dt     AS dt
         FROM     test1
        UNION
         SELECT     key
         ,     end_dt          AS dt
         FROM     test1
    )
    ,     ranges          AS
    (
         SELECT  key
         ,     dt                    AS start_dt
         ,     LEAD (dt)     OVER ( PARTITION BY  key
                                        ORDER BY          dt
                           )          AS next_dt
         FROM     change_points
    )
    SELECT    r.key
    ,       r.start_dt
    ,       r.next_dt - CASE
                         WHEN  r.next_dt = MAX (r.next_dt) OVER ()
                    THEN  0
                    ELSE  1
                      END                         AS end_dt
    ,       MAX (CASE WHEN t.cd = 'A' THEN 'Y' ELSE 'N' END)     AS a_ind
    ,       MAX (CASE WHEN t.cd = 'B' THEN 'Y' ELSE 'N' END)     AS b_ind
    ,       MAX (CASE WHEN t.cd = 'Q' THEN 'Y' ELSE 'N' END)     AS q_ind
    FROM       ranges     r
    JOIN       test1          t  ON   t.key          = r.key
                        AND     t.start_dt     < r.next_dt
                      AND     t.end_dt     > r.start_dt
    GROUP BY  r.key
    ,            r.start_dt
    ,       r.next_dt
    ORDER BY  r.start_dt
    ;
    

    Note that this depends on the values that you want in the columns a_ind, b_ind and q_ind. For example, if you were doing this for users of German language, you might want to show 'J' and 'n' instead of 'Y' and 'n'. In this case, you would use MIN instead of MAX, to get the dominant value.

  • obtaining the previous value of the previous row

    Hello

    My desired output should be

    ID Book_date credit Previous_Credit
    123IT1 08/12/2008 100800 72500


    in this table:

    ID book credit date
    123IT1 08/12/2008 100800
    123IT1 12/18/2007 72500
    123IT1 14/11/2006 150720

    I tried to use the function of leader, but I have a problem when I included the condtion Beach date:

    This is my query:

    SELECT id, book_date, lead (credit), credit (any order of rownum) as previous_credit
    t
    "where book_date between 1 December 2008 and 31 December 2008"

    Result

    ID Book_date credit Previous_Credit
    123IT1 08/12/2008 100800
    The previous_credit column is always empty. I think because of the date range... ?

    No idea how to get the right result? pls help
    with t as ( -- generating sample data
    select '123IT1' id, to_date('12/8/2008', 'mm/dd/yyyy') book_date, 100800 credit from dual union
    select '123IT1', to_date('12/18/2007', 'mm/dd/yyyy'), 72500 from dual union
    select '123IT1', to_date('11/14/2006', 'mm/dd/yyyy'), 150720 from dual
    )
    --
    -- actual query
    --
    select *
    from ( select id
           ,      book_date
           ,      credit
           ,      lag(credit) over (partition by id order by book_date) as previous_credit
           from   t
         )
    where  book_date between to_date('12/01/2008', 'mm/dd/yyyy') and to_date('12/31/2008', 'mm/dd/yyyy')
    
  • Difference between the current and previous row in a table

    Hi all

    I'm having a problem with the request. Some help please can me?

    I need to get the difference between the previous row and current row in a table. I have a table, given as below.

    TABLEX
    ================

    Date items name

    AAA 100 01 - SEP - 09
    BBB 101 02 - SEP - 09
    CCC 03-AUG-09 200
    DDD 200 04 - SEP - 09
    EEE 05-SEP-09 400

    Now, I need to get an output like below...

    Name Date of items Diff-items

    AAA 01 / SEP / 09 100 0
    BBB 1 101 02 - SEP - 09
    CCC 03-AUG-09 200 99
    DDD 04-SEP-09 200 0
    EEE 05-SEP-09 400 200

    Can someone help me write a query to get above the results?
    Please let me know if you need more information.

    Thank you very much in advance.

    We use Oracle10G (10.2.0.1.0).

    Thank you
    Asif

    If you have found your answer, mark it as answered. Thank you.

  • Store the new values in the table in the new row so that the 'old' remains in the previous lines

    Hello

    I am a student of genius embedded. I did a VI where I change the values of digital controls, and it saves it as a table.
    I want to store the pair of new values in the new row of this table.
    I have attached a VI where I can change the values of numeric control, as well as the number of lines from another control. But when I change the values, all values in the output table change including values in the previous row. I want these lines to be unchanged and that new line to update.

    Need help.

    If I understand correctly, you want to always 4 models. If so a 2D table will do the trick (see annex VI), otherwise crossrulz' solution should work.

  • I'm opening table row in a popup with the help of change. If I opened a line to edit, and then if I cancel the popup and if I open some row of the table, then instead of the newly selected line diff, previously selected line becomes open question. Help, p

    @Code is:-

    I have a panelCollection which is having an ADFTable (VO) and < f: toolbar > < coomandToolbarbutton > IE change by clicking on modify the selected line of the tbal adf becomes open in edit mode in a popup. Buttong ActionListner change creation popup

    {} public void handleEdit (ActionEvent actionEvent)
    Add the code in the event here...

    Line selectedRow =
    (Row) ADFUtils.evaluateEL ("#{bindings.") BtEsAwardsSchemeSetupVO1Iterator.currentRow}");
    Line selectedRow =
    (Row) ADFUtils.evaluateEL ("#{bindings.") BtEsAwardsSchemeSetupVO1.currentRow}");

    Tips RichPopup.PopupHints = new RichPopup.PopupHints ();

    this.getAddEditpopup () .show (hints);
    }

    Pupup has two buttons for Submit and cancel.
    Click on Cancel button on the popup, it id hide. The question is, suppose that the table is to have 4 lines so if I first select third row and click on change that becomes open editing on a popUp, but if I click on the Cancel button and their selection a few rows of table (Say first line), the previously selected (3rd row) rank only becomes open again in popup instead of the newly selected row.
    Cacel code

    {} public void handleCancelAwards (ActionEvent actionEvent)

    Add the code in the event here...

    ADFUtils.invokeEL ("#{bindings.") Rollback.Execute}");

    this.getAddEditpopup (.cancel ()); [I also tried with hide and seek but not worked]

    }

    Thanks in advance and thanks for your time

    It may be a problem with the combination of: immediate = true, rollback, and af:popup.

    You can try adding af:resetActionListener to the Cancel button.

    BTW, your managed bean is in the package that start with uppercase ("Bean"). (if you should refactor this to "beans" (for example))

    Dario

  • APEX 4.2.5: How reference a column element in the previous line?

    Good afternoon

    I have the following problem:

    I have an IR on a table that contains the values of daily clock of energy (gas and electricity).

    Now, I want to set up a calculated column that contains the daily consumption.
    Power_actual_row - power_previous line.

    Is this possible and if yes how can I achieve this?

    Kind regards.

    Wilfried

    Baerenmarke wrote:

    I have the following problem:

    I have an IR on a table that contains the values of daily consumption of energy (gas & electricity) clock.

    Now, I want to set up a calculated column that contains the daily consumption.
    Power_actual_row - power_previous line.

    Is this possible and if yes how can I achieve this?

    Add a POWER_PREVIOUS column to your report query using the analytical function LAG to access the value of the POWER of the previous row. Use the ORDER byclause in the function to determine the order of the lines. The calculation of the IR then simply uses the POWER and POWER_PREVIOUS values for the same line.

  • 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

  • Camileo S20 does not save to the new 16 GB SDHC card

    Camileo s20 won't record I bought a new card 16 GB sdhc for camcorder and it will not save keeps saying memory full, I can record only for 1 min without cardAny suggestions please?

  • How can I save my iPhone if it's not new and I don't want to restore from old session?

    So, I've been really bad at backing up my iPhone. I have the iPhone 6 and had essentially when it came out. I backed up the phone right about then (11/10/14). Since then, I've only really imported my photos in iPhoto, but has not actually backed up t

  • Order the CD of restoration to the Canada

    Hello everyone. I bought an Acer Aspire e1-571-6471, a year ago. He received minimal useage. Recently I tried to upgrade to 8.1 Windows.  I received the message "failed to configure Windows updates" and he went into a loop.  I went through the standa

  • Code [0 x 80082202]

    I have an old pc that allows you to be part of a network. The company is out of bussiness and I acquired this Micron pc with windows xp pro sp2 already installed. Microsoft says that the code is not good. I don't know that it was when it was in use i

  • How to make objects pre-existing graphics raster?

    Hi, I have this png file I created using the character of RPG Maker MV generator. When I open the file there is of course no objects that I can choose. My first question is: How can I create objects of different characters and a row of characters? Wh