Calculate the sum involved new VO

Gurus,

I want to have a sum of column values in a table. I looked at a number of post on OTN, but it does not work
Created a transitional attribute in the VO. expression and passed to the next value
VO.getRowSet().sum("((Mtd == null) ? 0 : Mtd)
also tried
adf.object.getRowSet().sum("((Mtd == null) ? 0 : Mtd)
and
object.getRowSet().sum("((Mtd == null) ? 0 : Mtd)
MTD is the column in the original Version I want to calculate the total

Can you please advice what's not here

thnks

Published by: in the line of fire on August 10, 2011 10:46

I've tried this so 11.1.1.4, not 11.1.1.5 but it should work.

You can keep the condition in the expression:
object.getRowSet (.sum) (' bat == null? 0: Mtd')
to make sure that you have no problem with null values.

Apart from this, make sure that everything is in the type of data in the database and the VO.

Gabriel.

Tags: Java

Similar Questions

  • CALCULATE the sum of the amounts?

    Hey guys!

    This script:
    CLEAR      COMPUTES 
    CLEAR     BREAKS
    
    SET     feedback     off
    SET     pagesize     5000
    SET     linesize     50
    SET     echo          off
    SET     heading          on
    SET     verify          off
    
    COLUMN     User format     A8
    COLUMN     Files format     999999999
    COLUMN     Docs format     999999999
    COLUMN     Pages format     999999999
    
    COMPUTE SUM LABEL TOTAL OF "FILES", "DOCS", "PAGES"
    
    PROMPT     ************************************************** 
    PROMPT     *         Monthly File Activity by User          *
    PROMPT     ************************************************** 
    PROMPT      
    PROMPT      
    ACCEPT     StartDate     DATE FORMAT 'MMYYYY'      PROMPT 'Enter the month and year (MMYYYY): '
    PROMPT     
    PROMPT      List of users:
    PROMPT      One
    PROMPT      Two
    PROMPT      Three
    PROMPT      Four
    PROMPT      Five
    PROMPT      Six
    PROMPT      Seven
    PROMPT     UNKNOWN
    PROMPT       
    PROMPT     Type 'ALL', or leave blank, to select all users.
    PROMPT      
    ACCEPT     UserChoice     DEFAULT 'ALL'     PROMPT 'Please enter a user: '
    
    
    SELECT
         (CREATOR_ID
                       WHEN     '1'     THEN     'One'
                     WHEN     '2'     THEN     'Two'
              WHEN     '3'     THEN     'Three'
              WHEN     '4'     THEN     'Four'
              WHEN     '5'     THEN     'Five'
              WHEN     '6'     THEN     'Six'
              WHEN     '7'     THEN     'Seven'
              ELSE     'UNKNOWN'
              END)     "USER",
         count       (distinct(substr(DOC_NAME,1,9))) AS Files,
         count     (DOC_IMAGE) AS Docs,
         sum     (DOC_PAGE) AS Pages
    FROM
         TABLE1,
         TABLE2
    WHERE
         DOC_DATE to_date('&StartDate','MMYYYY') AND last_day(to_date('&StartDate','MMYYYY'))
    AND
         CREATOR_ID not in ('Thing','8','9')
    AND
         ((CREATOR_ID
                       WHEN     '1'     THEN     'One'
                     WHEN     '2'     THEN     'Two'
              WHEN     '3'     THEN     'Three'
              WHEN     '4'     THEN     'Four'
              WHEN     '5'     THEN     'Five'
              WHEN     '6'     THEN     'Six'
              WHEN     '7'     THEN     'Seven'
              ELSE     'UNKNOWN'
              END) = UPPER('&UserChoice')
         OR
         '&UserChoice' = 'ALL')
    GROUP BY
         CREATOR_ID
    /
    produces this result:
    USER          FILES       DOCS      PAGES
    -------- ---------- ---------- ----------
    One             261       4276      18124
    Two             364       5954      26913
    Three           109       1996       8243
    Four            178       3635      14554
    Five            104       2657      11662
    Six             308       6639      27887
    I would like for a labeled sum TOTAL at the bottom of these figures. I thought that COMPUTE would take care of this, but it's not. Am I missing something? It will not add these to the top because they are already money from specific users? Insight? I'm new to SQL and would like to be pointed in the right direction. Thanks for your expertise!

    I'm on a 10g system.

    Calculation is not SQL and SQL * more.
    The general syntax is
    calculate the sum of... the * | * report

    followed by
    break the report
    When this is necessary.

    -----------
    Sybrand Bakker
    Senior Oracle DBA

  • How to calculate the sum of the fields to fill?

    Hello!

    My question is how can I calculate the sum of filled areas?

    For example, in a PDF document, I have a few fields that must be filled out with name and surname and the end of the document, another field that is the sum of the fields "FullName" which shows how many people is in this document. The operation should not take into account white/empty areas.

    Now, I know that I could do with the simple calculation "(+) sum" but I have to put a '1' for each of this area and I would like to avoid this.

    Yes, it's the first option I described. In this case, you can use this code:

    var total = 0;
    for (var i=1; i<=79; i++) {
        if (this.getField("Nume si prenume "+i).valueAsString!="") total++;
    }
    event.value = total;
    
  • How to calculate the sum of two digital form fields based on the selection of the checkbox.

    I have a form in Acrobat Pro who needs a custom calculation. How to calculate the sum of two digital form fields based on a selection of the checkbox. I have three number fields. Field-A and B are simple one or two digits. Field-C is the sum, or the total field. I want to field-C have a control box which, when turned on and off, just gives a. gives the sum of A + B

    _ Field - 2

    _ Field - A 4

    [check] _ _ field - 6 C

    [disabled] _ _ field - 2 C

    Thank you

    The custom field C calculation script could be:

    (function () {
    
        // Get the values of the text fields, as numbers
        var v1 = +getField("A").value;
        var v2 = +getField("B").value;
    
        // Set this field's value based on the state of the check box named "CB"
        if (getField("CB").value !== "Off") {
            event.value = v1 + v2;
        } else {
            event.value = v1;
        }
    
    })();
    

    Replace 'A', 'B', and 'CB' with the real names of the fields.

  • Calculate the sum of the columns

    Hello!

    Am using jdeveloper 11.1.2.1

    I created a table VO based EO. I need to calculate the sum of the column named price.

    I use the expression PoView.sum ("Price"). In this PoView is the name of VO and the price is the name of the column.

    While spin AMModule I got an exception like

    PoView name not found in the given object.

    Hello

    You must use the name accessor EO or VO instead of the name of VO.
    See https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in (there are even the same error message in one of the comments of this blog)

    concerning
    Peter

  • calculate the sum of the two columns - display the result in the third column

    Hello

    I have a report and I want to calculate the sum of the two columns of the report and display the total in the third column.

    For example: Sample_My_Report

    Col1 Col2 (Col1 and Col2) Total

    3-7-10


    can someone help me with this question.

    Thank you.

    Hello:

    If your report is an IR you can use the menu "Tool" to add columns calculated at the State

    CITY

  • Calculate the sum of the duration stored in format HH24

    Dear professionals,

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production. I stored length of certain events in the table TIME_DURATION as as follows (format h24:mi):

    CREATE TABLE "TIME_DURATION" ("ID" NUMBER(11,0), "HOURSMINUTES" VARCHAR2(5));
    
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('5','00:55');
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('7','00:18');
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('9','06:34');
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('15','00:12');
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('17','09:50');
    INSERT INTO TIME_DURATION (ID,HOURSMINUTES) VALUES ('41','12:39');
    

    select * from time_duration;
    
            ID HOURS
    ---------- -----
             5 00:55
             7 00:18
             9 06:34
            15 00:12
            17 09:50
            41 12:39
    
    6 rows selected.
    

    Now, I want to calculate the total time for all events (sum of all specific times). In this case, it should be 30 hours and 38 minutes.

    Any help would be much appreciated.

    Thanks in advance.

    Hello

    So, you want to add a number of lines varibale.  This sounds like a job for the SUM function.  AMOUNT of work on numbers, no channels such as time, so use TO_NUMBER to convert strings to numbers, so you can add them.  If you want to display the result as a string, you can use TO_CHAR to convert the sum into a string.

    WITH got_total_minutes AS

    (

    SELECT SUM ((TO_NUMBER (SUBSTR (heure, 1, 2) * 60)))

    + TO_NUMBER (SUBSTR (hour 4))

    ) AS total_minutes

    OF time_duration

    )

    SELECT TRUNC (total_minutes / 60). ':'

    || To_char (MOD (total_minutes, 60))

    , "FM00.

    ) AS total_hours_minutes

    OF got_total_minutes

    ;

    The output is not quite what you asked:

    TOTAL_HOURS_MINUTES

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

    30: 28

    If you really want 30:38', explain how to get it.

    This solution assumes that time always is always 5 characters (2 digits, a separator and another of 2 digits) as it is in your sample data.

    If your actual data aren't like your sample data, the same approach still works, but the SUBSTR expressions will be more complicated.

    adnanBIH wrote:

    Dear professionals,

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production. I stored length of certain events in the table TIME_DURATION as as follows (format h24:mi):

    1. CREATE TABLE 'TIME_DURATION' ('ID' NUMBER (11.0), VARCHAR2 (5)) 'HOUR '.
    2. Insert into TIME_DURATION (ID, TIME) values ('5',' 00:55 ');
    3. Insert into TIME_DURATION (ID, TIME) values ('7',' 00:18 ');
    4. ...

    Thanks for posting the CREATE TABLE and INSERT.

    ID is a NUMBER, so do not use quotes around it:

    Insert into TIME_DURATION (ID, TIME) values (5, ' 00:55 ');

    Insert into TIME_DURATION (ID, TIME) values (7, ' 00:18 ');

    ...

    Depending on how you plan to use the hour, you may want to store a NUMBER, also, or maybe an INTERVAL DAY TO SECOND.

  • to calculate the sum...

    Hi all

    I have table as A B C D I want to create a new liike table this A B C D E
    1 2 x 1 2 1 x 1 x 20
    2 3 x 2 x 3 2 x 2 x 20
    3 4 x 3 x 3 4 x 3 x 20
    5 6 y1 y1 YY 5 6 96
    7 8 y2 y2 YY 7 8 96

    I am writing my syntax like this

    SELECT a, b, c, d, SUM(a*b) AS f FROM xyz GROUP BY d, a, b, c;

    I get only product of A and B, but I still want the sum OF THE PRODUCTS accordingly with D...

    Please correct where I am doing wrong...

    Thank you
    Mike
      1  with x as (
      2    select 1 a, 2 b, 'x1' c, 'x' d from dual
      3    union all
      4    select 2, 3, 'x2', 'x' from dual
      5    union all
      6    select 4, 5, 'x3', 'x' from dual
      7    union all
      8    select 6, 7, 'y1', 'y' from dual
      9    union all
     10    select 8, 9, 'y2', 'y' from dual
     11  )
     12  select a, b, c, d,
     13         sum( a*b ) over (partition by d) e
     14*   from x
    SQL> /
    
             A          B C  D          E
    ---------- ---------- -- - ----------
             1          2 x1 x         28
             2          3 x2 x         28
             4          5 x3 x         28
             6          7 y1 y        114
             8          9 y2 y        114
    

    Justin

  • Calculate the sum of values of 2 where Clauses

    Hi, sorry to trouble, I have all the data in a database or anything like that, just to think about some of the work I have to do, trying to get ahead. I was wondering how i would be the sum of the values in a column, but with 2 where clauses. By example, if I wanted to the sum of all the values until 18:00 in 1 column and all the after 18:00 for 1 day how I would write this out.

    I don't know how to write separately, i.e.

    select name, sum(values) as after6
    from table
    where time > '18:00'
    group by name;
    

    select name, sum(values) as upto6
    from table
    where time < '18:00'
    group by name;
    

    How can I combine these columns after6 and upto6 next to each other.

    If someone could please advise.

    Thanks in advance

    Select the name,

    sum (case when time > 18:00 ' then 0 otherwise end of values) as after6,.

    sum (case when time< '18:00'="" then="" values="" else="" 0="" end)="" as="">

    table

    Group by name;

    ----

    Ramin Hashimzade

  • How to calculate the sum (discount) when check box status = 'Y '.

    Hai.
    It's Vinet I want sum (disc) of particular elements check box STATUS = 'Y'
    I selected the quota_det TABLE data

    I have 5 codes elements
    SNO Agenda ITEMCODE QTY. BASIC PRICE DIS_PER DISK STATUS

    1 DELL 2 30000 60000 5 57000 D26OO Y

    2 HP HP2300 1 20000 20000 2 19600 N

    3 SAMSUNG SM560 2 5300 10600 3 10282 N

    4 NOKIA 5 25600 128000 3 125440 NK63 Y

    5 HTC 1 2300 2300 2 2254 HT25 Y


    ALL ARE ELEMENTS of DATABASE BUT STATUS IS NOT a basic ELEMENT of DATA THAT IS the POINT of the BOX

    VALUE CHECK = Y
    A VALUE WHEN UNCHECK = N

    IN above DATA I WANT ONLY ELEMENTS SUM (DISC) WHEN the POINT of the BOX CHECK THAT the SUM SHOULD BE APPEAR IN TOT_VALUE * POINT *.

    SEND ABOVE CODE REQUIREMENT WITH THE NAMES OF TRIGGER ITS URGENT...

    Published by: 988532 on March 22, 2013 22:27

    Hi Vincent!

    You can try this!

    Make another text point something as a disc_copy between the disc and on the same block
    below this text element properties
    1 piece of data: No.
    2. data type: number
    3 canvas: Null

    Create another element of text like total_discount below the properties

    1 piece of data: No.
    2. data type: number
    3 method of calculation: summary
    4. function: sum
    5. block of summaries: YourBlock
    6 point summaries: disc_copy

    If you are multi block record is then
    7. number of items: 1

    Set property YourBlock
    All records in the query: Yes

    Now, about the situation to apply trigger WHEN-CHECK-BOX-CHANGED and write below the code in this trigger

    if :YourBlock.status='Y' then
    
         :YourBlock.disc_copy:=:YourBlock.disc;
    else
         :YourBlock.disc_copy:=0;
    end if;
    

    Published by: XeM on 23 March 2013 12:06 AM

    Published by: XeM on 23 March 2013 12:07 AM

  • To calculate the sum Vals and LV is higher than its target line LV

    When I answered this thread of application of the hierarchy and the number of subnodes
    I made this question.

    I use Oracle11gR2.

    I want the sum Vals and LV is superior to his LV of the target line to the command by sorkKey.
    Ex if LV 2, sumVal is the sum of this line and another line which LV > 2.
    MyTable
    sortKey  LV  Val
    -------  --  ---
          1   2   10
          3   3   20
          5   4   30
          6   3   40
          7   4   50
          9   2   60
         15   3   70
         16   4   80
    with MyTable(sortKey,LV,Val) as(
    select  1,2,10 from dual union
    select  3,3,20 from dual union
    select  5,4,30 from dual union
    select  6,3,40 from dual union
    select  7,4,50 from dual union
    select  9,2,60 from dual union
    select 15,3,70 from dual union
    select 16,4,80 from dual)
    expected Output
    sortKey  LV  Val  sumVal
    -------  --  ---  ------
          1   2   10     150   (10+20+30+40+50)
          3   3   20      50   (20+30)
          5   4   30      30   (30)
          6   3   40      90   (40+50)
          7   4   50      50   (50)
          9   2   60     210   (60+70+80)
         15   3   70     150   (70+80)
         16   4   80      80   (80)
    If you use subQuerys, the solution is below.
    But it's very complex :-(
    My question is "is it more simple solution?
    For ex using fuction OLAP, model clause etc...
    with MyTable(sortKey,LV,Val) as(
    select  1,2,10 from dual union
    select  3,3,20 from dual union
    select  5,4,30 from dual union
    select  6,3,40 from dual union
    select  7,4,50 from dual union
    select  9,2,60 from dual union
    select 15,3,70 from dual union
    select 16,4,80 from dual)
    select sortKey,LV,Val,
    (select sum(b.Val)
       from MyTable b
      where a.sortKey <= b.sortKey
        and b.sortKey <
            (select nvl(min(c.sortKey),99999)
               from MyTable c
              where c.sortKey > a.sortKey
                and c.LV <= a.LV)) as sumVal
      from MyTable a;

    In fact, it can be simpler:

    with t as (
               select  1 sortkey,2 lv,10 val from dual union all
               select  3,3,20 from dual union all
               select  5,4,30 from dual union all
               select  6,3,40 from dual union all
               select  7,4,50 from dual union all
               select  9,2,60 from dual union all
               select 15,3,70 from dual union all
               select 16,4,80 from dual
              )
    select  sortkey,
            lv,
            val,
            sum(val) over(order by sortkey range between current row and rng following) sumval
      from  (
             select  sortkey,
                     lv,
                     val,
                     nvl(
                         (select min(b.sortkey) from t b where b.sortkey > a.sortkey and b.lv <= a.lv) - a.sortkey - 1,
                         max(sortkey) over() - a.sortkey
                        ) rng
               from  t a
             )
      order by sortkey
    /
    
       SORTKEY         LV        VAL     SUMVAL
    ---------- ---------- ---------- ----------
             1          2         10        150
             3          3         20         50
             5          4         30         30
             6          3         40         90
             7          4         50         50
             9          2         60        210
            15          3         70        150
            16          4         80         80
    
    8 rows selected.
    
    SQL> 
    

    SY.

  • Calculate the sum of the 2 columns in the total column.

    Hello everyone.

    I have a question I hope you can help us

    I use the form of oracle 10 g , I made the table student FYI There are 5 columns ( HomeWorks, project, Midterm1, Midterm2,FinalExam), , I need to calculate these brands and put it in ( Total ) column using the form of the oracle. How to? .

    Another thing is it possible for me to restrict the user so that he can not enter more than 10 points for homework and not more than 15 points for project, etc.?

    I hope you can answer me I am really really really really grateful that I searched online, but no real solution especially for the second part of the question. will I change the varchar2 to the numbers?

    Thank you

    Yes... What you have to do is, you create when validating the element trigger on assignment, then put under code of the project

    IF (: blockname.itemname) > 20 THEN

    MESSAGE ("you must enter only less than 20 brands '");

    RAISE FORM_TRIGGER_FAILURE;

    END IF;

    Make the total, rank as a display element. Create a button contained within this block and put the code below in this WHEN the BUTTOM PRESSED trigger

    DECLARE

    v_total NUMBER;

    BEGIN

    v_total: =: Blockname. Mid1 +: Blockname. MID2 +: blockname.assignment +: Blockname. Final +: Blockname. Project;

    : blockname.total: = v_total;

    : blockname.grade: = CASE WHEN v_total<60   then ="">

    WHEN v_total<65   then ="">

    WHEN v_total<70   then ="">

    WHEN v_total<75   then ="">

    WHEN v_total<80   then ="">

    WHEN v_total<85   then ="">

    WHEN v_total<90   then ="">

    WHEN v_total<95   then ="">

    WHEN v_total<=100 then="">

    END;

    END;

  • How to calculate the sum of the numbers in a table...

    So my table contains brands for a fictitious class and I need to be able to calculate these brands to give me an average of class which is this formula; all brands added / number of brands. Is there a way to do this in a table?

    My code for the program so far is:

    Create table
    var brands: Array = ["100" '76', '80', '54', '23'];
    Function key
    enter_btn.addEventListener (MouseEvent.CLICK, onClick);
    function onClick(event:MouseEvent):void {}
    Declare required variables
    var brand: Number;
    markIn var: String;
    Retrieve data from TextField
    markIn = markIn_txt.text;
    brand = Number (markIn);
    Table
    Marks.push (markIn_txt. (Text);
    trace (Marks);
    }

    Add a listener to mouse for the sorting of the brands
    sort_btn.addEventListener (MouseEvent.CLICK, onSort);
    function onSort(event:MouseEvent):void {}
    Matrix display and sorting
    marksort_txt. Text = marks.sort (Array.NUMERIC);
    }

    Add a listener for mouse for analyizing brands
    analysis_btn.addEventListener (MouseEvent.CLICK, onAnalysis);
    function onAnalysis(event:MouseEvent):void {}
    Determine the middle class

    NOTE: I had this total = total + Number (mark [k]); inside a loop but it doesn't seem to work...

    Maybe something like that might work for you.

    var brands: Array = ["100" '76', '80', '54', '23'];

    var totalMark:Number = 0;
    var avgMark:Number = 0;
    var markCount:uint = 0;

    for (var i: int = 0; i
    {
    var mrk:Number = parseInt (marks [i]);
    If (IsNaN (MRK)) {continues ;}
    markCount ++;
    totalMark += mrk.
    }
    avgMark = totalMark/markCount;

    trace (Marks);
    trace (totalMark)
    trace (avgMark)

  • How to calculate the sum of the values of some columns in a table

    Hello

    I want to get the column just the average of the values of some columns not all columns of the table.what I have to change exactly in this block diagram.even if the table size is 25 average, I want the division as the number of values in each column (= number of lines)

    just like that:


  • Dynamic calc to calculate the sum of the months in the years

    I have a 6.5.5 Essbase cube with a size of periods containing months and weeks as members stored, labeled as time. I also have a dimension of the year that contains exercises and these members can also be stored. I have to add together the first month of this year and the last month of last year.

    I can do this:

    M12-LY + M01-> TY >

    Gives me the right answer and I could configure IF statements through Sunday to the correct value of LY, but I would like the formula dynamically select the correct LY based on the year TY that the user puts in place in their query. I tried some combos using @prior and @shift and it is not working properly.

    Here is what I thought might work:

    M01 + (@SHIFT (Year-1));

    This formula results by adding just the M01 and nothing of LY. Any thoughts on how to configure this formula?

    Published by: user11908498 on 16 Sep, 2009 05:55

    Published by: user11908498 on September 16, 2009 11:42

    What your year Sun look like?

    The support is that it looks like this

    Year
    -2008 (LY)
    -2009 (TY)

    So if you're on TY, then shift - 1 (or before) it would go to the 2008 (LY)

    By chance your year sun goes in the opposite direction

    Year
    -2009 (TY)
    -2008 (LY)

    In this case, you will have to go the other way

    "M01" + @SHIFT ("M12", 1, @CHILDREN ("Year"));

Maybe you are looking for