the sum of a column where date column is converted in year + 1

Hello

I want the sum, said the column of taAmt where he is not null and the column fromPeriod is converted to the format of the year and has 1 year. This syntax does not work, can anyone help?

<? sum (taAmt [.! = "and fromPeriod ('YYYY') + 1])? >

Assigning :) Points If you wish

Tags: Business Intelligence

Similar Questions

  • Is there an alternative way to compute the sum of a column without accessor view

    Hi Experts,

    JDev 12 c,

    I have a column A and I'm total calculation of column A with the same VO as a view accessor. And calculating as below

    EmployeeViewAccessor.sum ("ColumnA").

    But this way, it loads the VO 2 times as it loads the accessor aswell.

    So is there an alternative way to calculate the sum of a column.

    Thank you

    Roy

    Use the analytical function, please see below Ex

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/functions163.htm

  • Calculation of the sum of a column on a XML editor RTF with NULL values

    Hello

    I have a problem to get the sum of a column in XML editor RTF, if one of the lines has a null value.

    say, I have 4 columns and values

    CASES1:
    NULL, NULL, 4, NULL
    Sum, I expect is: 4

    CASE2:
    NULL, NULL, NULL, NULL
    I'm waiting for is a null

    Is there a way to do this?

    Thank you
    Anita

    Try this

    AMT's column

  • How to get the last row and the sum of all columns in a query

    Hello

    is there a way to get the last record for a column and the sum of all the Archives to another column in the same query.

    Best regards

    You must set your needs correctly volunteers to help here...

    Your data are not good enough to bring you a precise solution. Purpose, you do not have a column, which draws a distinction between the first and the last entry.

    The solution becomes easy based on your design.

    I introduced a grouping called 'id' column and a time column called 'time_of_insert' (only this way you can say with confidence that you can differentiate between the first and last (also a foolproof solution) - you can possibly use sequence (instead of date but if you say that you can insert two lines at the same time) ((and then likely sequence would be a better choice to differentiate instead of a timestamp field) etc...)

    With your sample data, something like this can be done to get the desired results.

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

    WITH dataset AS

    (SELECT 1 id, 10 used, 8 remain, systimestamp + 1/24 time_of_insert FROM DUAL

    UNION ALL

    SELECT the 1 id, 1, 7, systimestamp + 2/24 FROM DUAL

    UNION ALL

    SELECT the id 1, 2, 5, systimestamp + 3/24 FROM DUAL

    UNION ALL

    SELECT 1 id, 1, 0, systimestamp + 4/24 FROM DUAL

    UNION ALL

    SELECT 1 id, 0, 0, systimestamp + 5/24 FROM DUAL

    UNION ALL

    SELECT the 1 id, 1, 4, systimestamp + 6/24 FROM DUAL)

    SELECT *.

    (SELECT SUM (used) ON sum_all)

    FIRST_VALUE (stay)

    COURSES (PARTITION BY id ORDER BY time_of_insert DESC)

    last_row

    Of THE dataset)

    WHERE ROWNUM = 1;

    Output:

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

    SUM_ALL LAST_ROW

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

    15                  4

    See you soon,.

    Manik.

  • JavaScript for the sum of a column cells

    Hi all -

    I have a table in expansion (lines can be added) and I am using the line of the column footer to calculate the average of the cells which do not have the value 0.

    Form Calc is usually great, but in this case, I need to divide the sum by the number of cells that are not zero and I don't know how to do this via form Calc.

    Successfully used javascript to identify the total number of occurrences and identify the number of instances that are zero, then the part of the denominator of the equation is fine. (Number of cases - number of zeros = denominator.)

    Now, it's just the numerator. There must be a loop, right?

    Is called table: table1

    Line is called: data

    cell is called: rated

    Any thoughts? Or more effective methods? Thank you very much.

    B

    Hello

    a solution in FormCalc could look this way:

    form1.#subform[0].table1.footer.sum::calculate - (FormCalc, client)
    var c = 0
    var s = 0
    for i = 0 upto (_data.count - 1) do
      if (data[i].eValue gt 0) then
      c = Sum(c, 1)
      s = Sum(s, data[i].eValue)
      endif
    endfor
    
    if (s gt 0 and c gt 0) then
      $ = Round(s / c)
    else
      $ = 0
    endif
    

    Put this scriot in the calculate of the cell of the footer line event.

  • A simple query to write for the SUM of a column

    Hello

    I have a Quantity column. I want his total.
    For a PURCHASE, I would like to add the value in the column Qunatity.
    For a COPY, I want to subtract the value in the column Qunatity.
    So overall, the sum of the column should give me total buy less total sells.

    Any help is welcome.
    Thank you.

    Published by: TechVortex on August 11, 2011 11:49

    Like this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  with sample_data as
      2  (
      3  select 100 quantity, 'B' flag from dual union all
      4  select 200, 'B' from dual union all
      5  select 100, 'S' from dual union all
      6  select 500, 'B' from dual union all
      7  select 200, 'S' from dual
      8  )
      9  SELECT SUM(quantity),
     10         SUM(DECODE(flag, 'B', quantity,
     11                          'S', -quantity)) absolute_sum
     12* FROM   sample_data
    SQL> /
    
    SUM(QUANTITY) ABSOLUTE_SUM
    ------------- ------------
             1100          500
    
  • SQL for the sum of a column while avoiding the repetition of values

    Dear all
    I have this table called Loans_installments that contains the client's loan payments.

    sample data:
    the client_id loan_no inst_mat_date inst_seq original_inst_amt int_amt currency management
    110 2 222 100 1/1/2013 1 0 50
    110 2 222 100 1/2/2013 2 0 52
    110 2 222 100 1/3/2013 3 0 54
    110 2 222 100 1/4/2013 4 500 90
    110 2 222 100 1/5/2013 5 0 50
    110 2 222 100 1/6/2013 6 0 51
    110 2 222 100 7/1/2013 7 0 50
    110 2 222 100 1/8/2013 8 600 105
    110 2 222 100 1/9/2013 9 0 50
    110 2 222 10 100 1/10 / 2013 0 54
    110 2 222 100 1/11 / 2013 11 0 50
    110 2 222 100 1/12 / 2013 12 700 120



    now what I want to do the sum of int_amt field based on original_inst_amt value (0 or a value) and put the result on the int_amt who has an orig_inst_amt value <>0.

    the result should be like this:


    the client_id loan_no inst_mat_date inst_seq original_inst_amt int_amt currency management
    110 2 222 100 1/1/2013 1 0 0
    110 2 222 100 1/2/2013 2 0 0
    110 2 222 100 1/3/2013 3 0 0
    110 2 222 100 1/4/2013 4 500 246
    110 2 222 100 1/5/2013 5 0 0
    110 2 222 100 1/6/2013 6 0 0
    110 2 222 100 7/1/2013 7 0 0
    110 2 222 100 1/8/2013 8 600 256
    110 2 222 100 1/9/2013 9 0 0
    110 2 222 100 1/10 / 2013 10 0 0
    110 2 222 100 1/11 / 2013-11 0 0
    110 2 222 100 1/12 / 2013 12 700 274


    any help please.

    With the help of the clause type

    SQL> with t
      2  as
      3  (
      4  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/1/2013','mm/dd/yyyy') inst_mat_date, 1  inst_seq, 0   original_inst_amt, 50 int_amt from dual
      5  union all
      6  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/2/2013','mm/dd/yyyy') inst_mat_date, 2  inst_seq, 0   original_inst_amt, 52 int_amt from dual
      7  union all
      8  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/3/2013','mm/dd/yyyy') inst_mat_date, 3  inst_seq, 0   original_inst_amt, 54 int_amt from dual
      9  union all
     10  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/4/2013','mm/dd/yyyy') inst_mat_date, 4  inst_seq, 500 original_inst_amt, 90 int_amt from dual
     11  union all
     12  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/5/2013','mm/dd/yyyy') inst_mat_date, 5  inst_seq, 0   original_inst_amt, 50 int_amt from dual
     13  union all
     14  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/6/2013','mm/dd/yyyy') inst_mat_date, 6  inst_seq, 0   original_inst_amt, 51 int_amt from dual
     15  union all
     16  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/7/2013','mm/dd/yyyy') inst_mat_date, 7  inst_seq, 0   original_inst_amt, 50 int_amt from dual
     17  union all
     18  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/8/2013','mm/dd/yyyy') inst_mat_date, 8  inst_seq, 600 original_inst_amt, 105 int_amt from dual
     19  union all
     20  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/9/2013','mm/dd/yyyy') inst_mat_date, 9  inst_seq, 0   original_inst_amt, 50 int_amt from dual
     21  union all
     22  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/10/201','mm/dd/yyyy') inst_mat_date, 10 inst_seq, 0   original_inst_amt, 54 int_amt from dual
     23  union all
     24  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/11/201','mm/dd/yyyy') inst_mat_date, 11 inst_seq, 0   original_inst_amt, 50 int_amt from dual
     25  union all
     26  select 110 branch, 2 currency, 222 client_id, 100 loan_no, to_date('1/12/201','mm/dd/yyyy') inst_mat_date, 12 inst_seq, 700 original_inst_amt, 120 int_amt from dual
     27  )
     28  select branch
     29       , currency
     30       , client_id
     31       , loan_no
     32       , inst_mat_date
     33       , inst_seq
     34       , original_inst_amt
     35       , decode(original_inst_amt, 0, 0, sum(int_amt) over(partition by cnt)) int_amt
     36    from (
     37            select branch
     38                 , currency
     39                 , client_id
     40                 , loan_no
     41                 , inst_mat_date
     42                 , inst_seq
     43                 , original_inst_amt
     44                 , int_amt
     45                 , cnt
     46              from t
     47             model
     48             dimension by
     49             (
     50                inst_seq
     51             )
     52             measures
     53             (
     54                branch, currency, client_id, loan_no, inst_mat_date, original_inst_amt, int_amt, 1 cnt
     55             )
     56             rules
     57             (
     58                 cnt[any] = case
     59                                   when original_inst_amt[cv()-1] > 0 then
     60                                      cnt[cv()-1] + 1
     61                                   else
     62                                      nvl(cnt[cv()-1], cnt[cv()])
     63                               end
     64             )
     65         )
     66  /
    
        BRANCH   CURRENCY  CLIENT_ID    LOAN_NO INST_MAT_   INST_SEQ ORIGINAL_INST_AMT    INT_AMT
    ---------- ---------- ---------- ---------- --------- ---------- ----------------- ----------
           110          2        222        100 01-JAN-13          1                 0          0
           110          2        222        100 02-JAN-13          2                 0          0
           110          2        222        100 03-JAN-13          3                 0          0
           110          2        222        100 04-JAN-13          4               500        246
           110          2        222        100 05-JAN-13          5                 0          0
           110          2        222        100 06-JAN-13          6                 0          0
           110          2        222        100 08-JAN-13          8               600        256
           110          2        222        100 07-JAN-13          7                 0          0
           110          2        222        100 09-JAN-13          9                 0          0
           110          2        222        100 11-JAN-01         11                 0          0
           110          2        222        100 10-JAN-01         10                 0          0
           110          2        222        100 12-JAN-01         12               700        274
    
    12 rows selected.
    
    SQL>
    
  • The sum of a column with 2 values using Forms 6i

    Hello world
    I have 2 blocks, a main block and the other is
    my block of retail and my block of retail element is a list item
    When I have 2 options to choose, we're for described video and the
    Another is for delay.
    My question is:
    How can I add an item in my form where I will summarize the
    amount of A and L is inserted on this column?

    I forgot about it. DECODE cannot be used in SQL. This time I tried the solution myself in Forms 6i, so I know it works. Set the formulas

    InStr(:Item,'A')

    This returns 1 if the value is A, 0 otherwise. Ditto for the L value of course.

  • Dynamics as the sum of two columns in another

    Hi all
    I'm new with apex, and I had a problem I think its simple but I can't do it :)
    problem is, I have a table with column 3 I need dynamic action on the value of change in two columns to summarize this in a 3rd.
    So I can be able to add 5 rows calculate the columns in row and submit them.
    X Y Z
    1 2 3
    2 2 4
    5 5 10
    Send

    Thank yor occasionally you

    Check this thread column calculated in table form. The same problem is discussed here.

  • How do the sum of several columns with grouping different criteria

    Currently I am doing a project where I needed to generate the report which retrieved from the table. the table as shown below

    CURRENCY_A AMOUNT_A CURRENCY_B AMOUNT_B CURRENCY_C AMOUNT_C

    USD 100 EURO 100 POUNDS 100

    EURO 200 BOOKS 200 200 USD

    BOOKS USD EURO 300 300 300

    My expectations is the grand total of the Group (AMOUNT_A + AMOUNT_B + AMOUNT_C) currency

    USD:

    EURO:

    BOOKS:

    Is it possible to do this output in oracle alone?

    Hello

    UNPIVOT before consolidation / summary:

    SELECT currency, flat

    DE)

    SELECT CASE WHEN 1 THEN currency_a n

    WHEN 2 THEN currency_b

    WHEN 3 currency currency_c end THEN

    CASE WHEN 1 THEN amount_a

    WHEN 2 THEN amount_b

    WHEN 3 amount of end of amount_c THEN

    From your_table

    CROSS JOIN (select column_value table n (sys.odcinumberlist (1,2,3))) t

    )

    GROUP BY currency

  • The sum of 2 columns

    Hello

    What I do is to summarize and out the hours and the amount related to the non

    either no 1 would have hours = 15 and qty = 3
     
    no     hours         qty
    --      -----       ---
    1     10         1
    1       5           2
    2       5           1
    2       10          2
    3       20          4
    4       5           3
    4       10          2
    Marco

    Hello

    SELECT no, SUM (Hrs), SUM (Qty) OF Tbl

    GROUP OF No.;

    See you soon,.

  • The sum of 2 columns per line

    Hi all
    Please help how this could be done.

    < product >
    < ProductOption >
    Product1 < ProdName > < / ProdName >
    rate <>
    Modem < ratename > < / ratename >
    < > 15 rate1 < / rate1 >
    < / rates >
    < / ProductOption >
    < ProductOption >
    Product2 < ProdName > < / ProdName >
    rate <>
    Modem < ratename > < / ratename >
    rate < 1 > 12 < / rate1 >
    < / rates >
    < / ProductOption >
    < / product >

    You use above XML structure, how do I display it in this format of table:

    Rate name Product1, Product2 Total
    Modem 15 12 27

    Thanks in advance!

    Can you send me your sample xml

  • 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.

  • The ABS function and the sum at a time

    <? If: sum (ARCH_AMT)! = '0' ? >

    We used above condition in the model to restrict the data to date, but we were faced with a new problem when ARCH_AMT is to have several lines with the same amount but + ve and ve - that is to say 500, -500, is the sum and do not return data given that the sum would be zero.

    We do ABS (ARCH_AMT) before making the sum that the SUM will be thousand and data will be collected.

    Please suggest how can we have ABS and the sum at a time

    I tried

    <? If: sum (ABS (ARCH_AMT))! = '0' ? > and also choose the conditions and it does not work.

    Thanks in advance.

    Kind regards
    Mahi

    Published by: mahi4luck on March 28, 2012 02:33

    store ABS (ARCH_AMT) in a variable and use this variable in a total cumulative

    example:
    Suppose I have a structure xml like this:



    -500


    500





    Total:

  • How do rotate on a date and see the sum of the value of another column

    Hello

    I searched through the forum and cannot find a query similar to my question feels so post this new thread.

    First of all, it is probably useful indicating that I am using Oracle 10 g.

    I have a table that is used to store the details of the booking (essentially a booking system) and I would use this data to display the details of the customers stay on one line.

    The table has the following columns:
    BOOKING_ID
    CUSTOMER_ID
    DATE_OF_ARRIVAL
    NUMBER_OF_NIGHTS
    NUMBER_OF_PEOPLE
    Some example records could be:

    BOOKING_ID    CUSTOMER_ID     DATE_OF_ARRIVAL    NUMBER_OF_NIGHTS   NUMBER_OF_PEOPLE
    --------------------------------------------------------------------------------------------
    1                    201      13-JAN-2010        5                   1
    2                    202      13-JAN-2010        3                   2  
    3                    202      13-JAN-2010        4                   1
    4                    203      15-JAN-2010        2                   3
    On this basis I would like to display the output so that I can show a sum of the NUMBER_OF_PEOPLE reserved to per customer per day, as such:
    CUSTOMER_ID     13-JAN   14-JAN   15-JAN   16-JAN   17-JAN   18-JAN   19-JAN 
    -----------------------------------------------------------------------------------------
    201                   1       1        1        1        1        0        0
    202                   3       3        3        1        0        0        0
    203                   0       0        3        3        0        0        0
    I watched analytical functions in the documentation and several books of Oracle that I have, but have so far struggled to find how to make the performance desired. Even using the excellent response to the previous post on the forum, I got Re: how to count the occurrence of a date in a range I was not able to get a feasible request.

    Any help or advice would be much appreciated.

    Kind regards
    Stu

    Published by: macmanxie on January 10, 2011 21:16

    Hello

    macmanxie wrote:
    ... The suggested approach goes only to return a number if the DATE_OF_ARRIVAL corresponds to the date in the CASE statement, however I have the added complexity of wanting to show a count of all the days that the customer is booked, for, by making use of the NUMBER_OF_NIGHTS. I tried to use some of the examples provided on morganslibrary.org, for example:

    sum( CASE WHEN  TRUNC (arrival_date) between '01/13/2011' and TRUNC (arrival_date+no_of_nights) THEN nvl(no_of_people,0) ELSE 0 END) AS jan_13
    

    but this does not produce the desired result.

    You check if arrival_date is between January 13 and arrival_date + no_of_nights (as if the arrival date could all be posterior to the arrival_date + no_of_nights).
    Are not really interested in whether or not January 13 ib between arrival_date and arrival_date + no_of_nights?

    NVL ( SUM ( CASE
                    WHEN  TO_DATE ( '01/13/2011'
                           , 'MM/DD/YYYY'
                         )          BETWEEN  TRUNC (arrival_date)
                             AND       TRUNC (arrival_date) + no_of_nights
                 THEN  no_of_people
             END
           )
        , 0
        )          AS jan_13
    

    Always format your code. It is important to format your code if you are the only who who will ever read but it is even more important if you are posting on a forum like this and ask other people to read.
    Not to compare the DATEs in the strings; explicitly use a conversion function, like TO_DATE, above, where necessary.
    Both
    SUM (NVL (x, 0)) and
    NVL (SUM (x), 0) get the same results, but the latter is more effective. If you have 1000 lines, the first way is calling NVL 1000 times, but the second way is calling only once.

    If your previous thread
    Re: How to count the occurrence of a date in a range
    Gets you the right data, but it has one row for each distinct combination of customer_id and date, then you can switch it to a form that contains a line by the customer and another column for each date.

    If you need help, post CREATE TABLE and INSERT statements for some examples of data and outcomes from these data. The post you are trying better to a request, including a subquery that gets no cross-the raw table dynamic results.
    There will be a fixed number of columns in the output swing? If this is not the case, how do you deal with that? Which of these options in the thread I posted above)
    Re: County report and the sum of the number of rows by multiple columns
    ) is best for your needs? Than others is acceptable?

Maybe you are looking for