How to Sum the intervals

Sir,
I would like to use the SUM function in summing the intervals like this statement:
SELECT
DATE_VALUE,
DAY_NAME ,
SUM(CAST(TIME_OUT as time) - CAST(TIME_IN as time)),
EMPLOYEE_ID
FROM [table name]
WHERE
[where clause]
GROUP BY
DATE_VALUE,
DAY_NAME ,
EMPLOYEE_ID ;Please note that: TIME_OUT, TIME_IN is timestamp;
But there is an error while executing this statement:
SUM(CAST(TXN_OUT as time) - CAST(TXN_IN as time)) ,
ERROR at line 9:
ORA-00932: inconsistent datatypes: expected NUMBER got INTERVALSo, how can I do sum for intervals.
Thank you in advance.

I am certain noone is looking for the ytom interval equivalence, but I liked to post it...
select numtoyminterval(
    sum(
    (   to_number(to_char(timestamp '3000-01-01 00:00:00' + x,'YYYY'))-
        to_number(to_char(timestamp '3000-01-01 00:00:00','YYYY'))
    ) * 12 +
        to_number(to_char(timestamp '3000-01-01 00:00:00' + x,'MM'))-
        to_number(to_char(timestamp '3000-01-01 00:00:00','MM'))
     , 'MONTH')
from
(select numtoyminterval(11, 'month') x from dual union all select numtoyminterval(1, 'year') from dual union all select numtoyminterval(100, 'year') from dual);
+000000101-11

Similar Messages

  • How to sum the column in a table seperated by sign.

    How to sum the column in a table separate by sign.
    For Example:
    A B
    10 MOHAN
    -15 KUMAR
    -25 MARCH
    50 MAY

    SELECT  SUM(CASE SIGN(A) WHEN 1 THEN A ELSE NULL END) SUM_POSTIIVE,
            SUM(CASE SIGN(A) WHEN -1 THEN A ELSE NULL END) SUM_NEGATIIVE
      FROM  tbl
    /SY.

  • How to Sum the datafield of a sub-group?

    Post Author: [email protected]
    CA Forum: General
    Hello guys,
    I am having this issue that I want to only Sum the datafield at sub-group level, not the detail level. But when I do the sum, it is adding all the details. The reason I am having this is because I have somewhat duplicated details (they complement each other). I merge them using group (by Item). The Item QTY is the feild that they all have and they have the same value, but I only need one of them. Now I want to group them by order number and show the total of items I ordered. I Sum all the items' QTY, but instead of sum the QTY that's merged, it sums all the QTY from detail. Basically I am suming duplicate numbers.
    Is there any solution to this? Thank you.

    Post Author: [email protected]
    CA Forum: General
    Hello Jagan,
    Thank you for the help. I treid the Average running total, but the problem is that I cannot do Summary on those new fields on the parent group. Also I can't get rid of the dupliate because the singel record does not contain enough info, I need all the records to merge togather to collect all the required inforamtion. Before I will just created a merged view on my DB to get rid of duplicate records. But this time, I am linking too much tables (includes external server DB table) that I can't make a view for that.
    Basically I have an order that splits into multiple invoices that get shipped using an external server where the Actual Ship Date does not write back to our own ordering system. I am trying to see if all my items are ship on time. So I need to merge all the items QTY from invoices that linked with external shipping DB, and group them in one order.
    The main problem I have is that I can't do summary on many custome fields. I can made the correct amount using Formula Field that has a shared flag to not include duplicate numbers. But once I use the shared flag, the forumla is no longer useable by Summary.
    Anyway, I think I will just use Excel instead. I already have all the proper data, just that when I do group summary in Crystal, it becomes a problem. I will export the data and do analysis from there.
    Thank you for the help

  • How to sum the  result rows at query designer

    Hi,
    We want to sum  the result rows which are at the end of the row by the help of query designer?So ,we directly see at analyzer
    exp:
       ..A.jan...A.feb...B.may...B.jun...SumA...SumB....SumA+B
    X..1............9..........6..............7........10.........13..........?????
    Edited by: zarata on Oct 23, 2011 12:49 PM
    Edited by: zarata on Oct 23, 2011 1:07 PM

    Hi,
    Could you please provide some more information.
    if you have characteristics iobject whose values are (A, B etc) and calendar month in rows and then at column level you have key figures then if you have turn on the "Display Result Rows" property of both iobject in Bex  as "Always" you can get the result. At the same time you can set "Display Overall result" property of the Query to get overall result.
    Regards,
    Pravin

  • How to sum the value of "N/A"

    I am new to javascripting and am trying to solve a problem with little success. Can anyone help. This is the situation:
    I am using Acrobat Pro 11 and I have created a form. I have 36 dropdown fields that for example have the following choices N/A, 5, 0 - I want to sum the value of all the N/A choices.  The value of each N/A is the largest number in the field. In my example it would be 5. I can assign a value to each N/A or the formula could look for the largest number in that dropdown field and add them together.
    Thank you in advance for any help you can provide.

    It's not possible. However, I can think of a couple of
    workaraounds:
    - Insert the value from the GLOBAL into the table that the
    trigger is on
    - Create a server-side package, declaring a variable in the
    package header. Assign the GLOBAL to the package variable before
    doing the commit on the Form.

  • How to sum the amount

    how can I add the amount shown below for year 1999. I would like to add all the amount between 01/22/1999 - 12/17/1999. thank you
    here is my simple sql looks like
    select sum(l.contamt),b.datelet
    from bidlet b, letprop l
    where b.LETTING = l.LETTING
    and l.LETSTAT='A'
    group by b.datelet
    Here is my desired out put
    Amount year
    xxxxxx 1999
    xxxxx 2000
    xxxxxx 2001
    24,692,441     01/22/1999 00:00:00
    30,625,058     02/26/1999 00:00:00
    810,879     03/16/1999 00:00:00
    45,415,715     03/19/1999 00:00:00
    34,359,502     04/09/1999 00:00:00
    34,967,761     04/23/1999 00:00:00
    1,396,831     05/04/1999 00:00:00
    40,408,333     05/14/1999 00:00:00
    37,556,062     05/28/1999 00:00:00
    19,583,374     06/11/1999 00:00:00
    45,105,742     06/25/1999 00:00:00
    6,096,878     07/23/1999 00:00:00
    369,439     08/17/1999 00:00:00
    15,293,129     08/27/1999 00:00:00
    9,249,995     09/10/1999 00:00:00
    9,078,176     09/24/1999 00:00:00
    2,153,323      10/22/1999 00:00:00
    6,239,335     11/19/1999 00:00:00
    26,908,007     12/17/1999 00:00:00

    user452051 wrote:
    how can I add the amount shown below for year 1999.You're very nearly there - all you need to do is convert your dates so they all represent just the year part - you can do this by using the TRUNC function to set the dates to the start of whatever year they belong to:
    eg.
    TRUNC(sysdate, 'yyyy')

  • How to sum the count results?

    Hi,
    I have this query:
    SELECT SUM (cnt) FROM
    select max(timestamp), min(timestamp), count(1) as cnt from table1
    union
    select max(timestamp2), min(timestamp2), count(1) from table2
    It display sum of all count results. But how to display each result from query and sum result at the end?
    Best.

    OK, thanks, that helps a lot. Though if you could put {noformat}{noformat} before and after your code snippets that would help further.
    So you basically want a total at the end:WITH test_data AS (
    SELECT 1 col1, TO_DATE('16-AUG-08', 'DD-MON-YY') max_ts, TO_DATE('16-AUG-08', 'DD-MON-YY') min_ts, 1000 cnt FROM DUAL UNION ALL
    SELECT 1, TO_DATE('31-OCT-08', 'DD-MON-YY'), TO_DATE('31-OCT-08', 'DD-MON-YY'), 1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('10-FEB-09', 'DD-MON-YY'), TO_DATE('01-JAN-01', 'DD-MON-YY'),422 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('20-FEB-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('20-FEB-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),14825 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('27-FEB-09', 'DD-MON-YY'), TO_DATE('27-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('28-FEB-09', 'DD-MON-YY'), TO_DATE('26-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('01-MAR-09', 'DD-MON-YY'), TO_DATE('01-MAR-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('05-MAR-09', 'DD-MON-YY'), TO_DATE('16-AUG-08', 'DD-MON-YY'), 5150 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('27-APR-09', 'DD-MON-YY'), TO_DATE('30-OCT-08', 'DD-MON-YY'),8733 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('27-APR-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),10000 FROM DUAL)
    -- end test data
    SELECT col1, max_ts, min_ts, sum(cnt) total_cnt
    FROM test_data
    GROUP BY ROLLUP((col1, max_ts, min_ts));
    1 16-AUG-08 16-AUG-08 1000
    1 31-OCT-08 31-OCT-08 1000
    1 10-FEB-09 01-JAN-01 422
    1 20-FEB-09 20-FEB-09 15825
    1 27-FEB-09 27-FEB-09 1000
    1 28-FEB-09 26-FEB-09 1000
    1 01-MAR-09 01-MAR-09 1000
    1 05-MAR-09 16-AUG-08 5150
    1 27-APR-09 30-OCT-08 8733
    1 27-APR-09 20-FEB-09 10000
    45130
    11 rows selected.

  • How to sum the quantity in opportunity ?

    Hi all,
    On the opportunity detail page, you can add an "opportunity product revenue". For each record you define the quantity and the purchase price. When you click on the "Update opportunity Totals", the revenue field from opportunity is automatically updated with the sum of the opportunity product revenues. I would like to do the same not with the revenue but with the quantity. Is it possible to do so, or is it an other way to get the sum of the quantity ?
    Thanks for your answer.
    Regards,
    Guillaume

    You cannot perform this function within the native application and you would need to create a webservice query to complete this

  • How to Sum the amounts for calculating rates.

    Hi,
    I have a requirement in Apps 11i (OAB) that I need to code in PL/SQL. I would be calling a procedure in order to complete this task. When an Extract is run, this code gets executed and should return the amount for that person.
    I need to calculate sum of all the amounts for each of the months between START date to the END date.
    Ex: Amount = Amount + (for each of the months between START and END date) x Rate.
    This START and END date would be calculated in the procedure itself.(dynamic).
    Once we get the START date and END date, we need to loop thru some records and find person's rate between those START date and END date.
    For rate calculation:
    15th day of any month is used as the cut off date for rate calculation.
    Suppose from 01-JAN-2006 to 15-MAR-2006 Rate is Rs 10 AND
    16-MAR-2006 to 01-JUL-2006 rate is Rs 20 AND person died on 01-JUL-2006
    Then rate = Rs(3x10) + Rs(3x20) + full month of July Rs.20 (P.S Here person's death needs to evaluated for the whole month) =30 + 60 + 20 = Rs.110
    Typically the start date and end date would be in one particular YEAR. And person may have different rates for different amounts as mentioned above.
    Let me if you need any more details..Thank You!
    Additional Info:
    This data comes from 2 tables in OAB Application where it can be joined with a common ID.
    One table lets say Coverage table contains the usual columns Eff_start_date, Eff_end_date along with this it has Coverage_start_date and Coverage_end_date (Dates specifying duration of the person enrolled in particular coverage.)
    P.S Rate Changes ONLY when the person enrolls in different coverage.
    2nd Table lets say Rate table contains the usual columns Eff_start_date, Eff_end_date along with this it has rate_start_date and rate_end_date and RATE(column) for that duration.(may vary depending upon the coverage).
    All the records should be between the START and END date, which will be calculated at runtime.
    Unable to submit any sample records.:-(
    Well, IF I had given the exact requirement, I would have got the solution by this Time!!! Your comments (and solutions) would definitely help me. Thank You
    Message was edited by:
    user559682

    If i understand you correctly it can be possible with :
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> drop table dates;
    Table dropped
    SQL> create table dates( "start" date, "end" date, "rate" number);
    Table created
    SQL> insert into dates values( to_date('01.01.2006', 'DD.MM.YYYY'), to_date('30.05.2006', 'DD.MM.YYYY'), 10);
    1 row inserted
    SQL> insert into dates values( to_date('01.06.2006', 'DD.MM.YYYY'), to_date('15.09.2006', 'DD.MM.YYYY'), 15);
    1 row inserted
    SQL> insert into dates values( to_date('16.09.2006', 'DD.MM.YYYY'), to_date('31.12.2006', 'DD.MM.YYYY'), 20);
    1 row inserted
    SQL> SELECT * FROM dates;
    start       end               rate
    01.01.2006  30.05.2006          10
    01.06.2006  15.09.2006          15
    16.09.2006  31.12.2006          20
    SQL> SELECT t.i, d."rate"
      2    FROM (SELECT add_months(to_date('01.01.2006', 'DD.MM.YYYY') /* start*/, LEVEL - 1) i
      3            FROM dual
      4          CONNECT BY LEVEL <= 12) t
      5        ,dates d
      6   WHERE t.i BETWEEN d."start" AND d."end";
    I                 rate
    01.01.2006          10
    01.02.2006          10
    01.03.2006          10
    01.04.2006          10
    01.05.2006          10
    01.06.2006          15
    01.07.2006          15
    01.08.2006          15
    01.09.2006          15
    01.10.2006          20
    01.11.2006          20
    01.12.2006          20
    12 rows selected
    SQL> SELECT SUM(d."rate") rs
      2    FROM (SELECT add_months(to_date('01.01.2006', 'DD.MM.YYYY') /* start*/, LEVEL - 1) i
      3            FROM dual
      4          CONNECT BY LEVEL <= 1 +
      5                     extract(MONTH FROM to_date('10.10.2006', 'DD.MM.YYYY') /*death*/) -
      6                     extract(MONTH FROM to_date('01.01.2006', 'DD.MM.YYYY') /* start*/)
      7          ) t
      8        ,dates d
      9   WHERE t.i BETWEEN d."start" AND d."end";
            RS
           130
    SQL>

  • How to sum the values based on the for all entries

    for example :
    select aufnr vornr sum (ISM02) sum ( ISM04) Sum (ism05) from afru into table I_afru for all entries of I_caufv where aufnr = i_caufv-aufnr group by aufnr.
    can any one help based on this query
    without forall entries it is working based for all entries only i want the solution Help me please.
    Regards
    Augustine

    Simple,
    select aufnr vornr ISM02 ISM04 ism05 from afru into table
    I_afru for all entries of I_caufv
    where aufnr = i_caufv-aufnr .
    <b>if sy-subrc eq 0.
    sort I_afru by aufnr.
    loop at l_afru.
    at end of aufnr.
    SUM.
    l_afru_temp = l_afru.
    append l_afru_temp.
    endat.
    endloop.
    endif.</b>

  • How to sum the result from 2 different queries?

    Hi ,
    I would like to add the reslut of the below queries and insert into the status_count column of the temp table called edr_status_by_report_data.
    How could I do that ?
    SELECT         
              COUNT(status_code)
        FROM (SELECT site_id,
                     site_lane_id,
                    (SELECT NVL(MAX(interval_start_date_time), date_time)
                       FROM edr_rpt_tmp_grouping_table
                      WHERE interval_start_date_time <= date_time) bin_start_date_time,
                            TO_NUMBER(TO_CHAR(date_time, 'hh24')) period,
                            vehicle_status  status_code
                       FROM edr_status_by_veh_data
                      WHERE vehicle_error_count = 0                         
                        AND vehicle_status > 0                   
             ) vehicles
    SELECT         
              COUNT(status_code)
        FROM (SELECT site_id,
                     site_lane_id,
                    (SELECT NVL(MAX(interval_start_date_time), date_time)
                       FROM edr_rpt_tmp_grouping_table
                      WHERE interval_start_date_time <= date_time) bin_start_date_time,
                            TO_NUMBER(TO_CHAR(date_time, 'hh24')) period,
                            vehicle_status  status_code
                       FROM edr_status_by_veh_data
                      WHERE vehicle_error_count = 0                         
                        AND vehicle_status = 0                   
             ) vehicles
          ;              

    That just becomes:
    SELECT count(*)
    FROM   (SELECT site_id,
                   site_lane_id,
                   (SELECT NVL(MAX(interval_start_date_time), date_time)
                    FROM   edr_rpt_tmp_grouping_table
                    WHERE  interval_start_date_time <= date_time) bin_start_date_time,
                   TO_NUMBER(TO_CHAR(date_time, 'hh24')) period,
                   vehicle_status status_code
            FROM   edr_status_by_veh_data
            WHERE  vehicle_error_count = 0
            AND    vehicle_status >= 0);Or, if you needed to have both columns separately for some other purpose, you could still get them in one query:
    SELECT COUNT(CASE WHEN status_code > 0 THEN 1) count_gt_zero,
           COUNT(CASE WHEN status_code = 0 THEN 1) count_zero,
           COUNT(CASE WHEN status_code > 0 THEN 1)
             + COUNT(CASE WHEN status_code = 0 THEN 1) total
    FROM   (SELECT site_id,
                   site_lane_id,
                   (SELECT NVL(MAX(interval_start_date_time), date_time)
                    FROM   edr_rpt_tmp_grouping_table
                    WHERE  interval_start_date_time <= date_time) bin_start_date_time,
                   TO_NUMBER(TO_CHAR(date_time, 'hh24')) period,
                   vehicle_status status_code
            FROM   edr_status_by_veh_data
            WHERE  vehicle_error_count = 0
            AND    vehicle_status >= 0);

  • How to sum the revenue based on new dimensional attribue?

    Experts,
    I have a requirement in which I want to report the monthly revenue based on a new attribue named cusotmer group.
    My existing customer dim hierarchy is something like this..
    customer_id -> customer_family -> Customer Segment -> Total Customer [No customer group]
    Now I introduce a new attribute customer group which has no relationship with the existing customer attributes or hierarchy. For example, a customer group, CG1 may correspond to any customer_id, customer_family and customer_segment. Now I want to report my revenue for every month based on the new customer group.
    NOTE : My customer dimension is very small (only 200 records) and we have added the customer group attribue column in the existing customer phyical table on database. We have around 12 distinct customer groups.
    Thanks for your help in advance

    Hi,
    Create alias column and place it in as a month level LBM and give the join between new attribute and fact .Now generate the report with revenue_alias and customer group.May you will the perfect results..
    mark if helpful/correct.....
    thanks,
    prassu

  • How to sum + group bp line items per a specific field?

    Hi,
    I found out about the SYS Numeric Query Based data definition, allowing me to sum the line items of a BP according to certain conditions.
    Now we have a more complex problem. We need to sum the line items of BP1 into the line items of BP2, grouping them by a given field. We know how to auto-create BPs on workflow events conditions, but we don't know how to sum the line items together.
    Is there a workaround?
    Thanks,
    S.R.

    We do not currently support QBDEs on line items so there isn't a way to sum values from other line items onto a line item.

  • How to sum

    Hi,
    May I know how to sum the units and amount in internal table? After summing, the value will be moved to new internal table.
    I try to do as below, but didnt get result. Perhaps something wrong? Can anyone help? Am very fresh in abap .. probably there are better ways to achieve this. Thanks.
    FORM GET_TOTAL .
    DATA : BEGIN OF WA_SUMM,
           PREV_LGORT TYPE LIPS-LGORT,
           TOTAL_LFIMG TYPE LIPS-LFIMG,
           TOTAL_STPRS TYPE MBEW-STPRS,
           TOTAL_TCOST TYPE LIPS-LFIMG,
           END OF WA_SUMM.
    DATA : IT_SUMM LIKE TABLE OF WA_SUMM.
    DATA : TOTAL_LFIMG TYPE LIPS-LFIMG,
           TOTAL_STPRS TYPE MBEW-STPRS,
           TOTAL_TCOST TYPE LIPS-LFIMG,
           PREV_LGORT TYPE LIPS-LGORT.
        SORT IT_OUTPUT BY LGORT.
        LOOP AT IT_SUMM INTO WA_SUMM.
          LOOP AT IT_OUTPUT INTO WA_OUTPUT.
          AT NEW LGORT.
              PREV_LGORT = WA_OUTPUT-LGORT.
              TOTAL_LFIMG = TOTAL_LFIMG + WA_OUTPUT-LFIMG.
              TOTAL_STPRS = TOTAL_STPRS + WA_OUTPUT-STPRS.
              TOTAL_TCOST = TOTAL_TCOST + ( TOTAL_LFIMG * TOTAL_STPRS ).
              MODIFY IT_SUMM FROM WA_SUMM TRANSPORTING PREV_LGORT TOTAL_LFIMG TOTAL_STPRS TOTAL_TCOST.
          ENDAT.
          ENDLOOP.
        ENDLOOP.

    See The sample code :
    Hi.
    TYPES: BEGIN OF G_I_DATA,
    PROFIT(4) TYPE C,
    COMPANY(4) TYPE C,
    ACCOUNT(10) TYPE C,
    AMOUNT TYPE P,
    END OF G_I_DATA.
    DATA: G_IT_DATA TYPE TABLE OF G_I_DATA,
    G_WA_DATA TYPE G_I_DATA.
    DATA: G_SUM_COMPANY TYPE P,
    G_SUM_PROFIT TYPE P,
    G_AMOUNT TYPE P.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 2000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 3000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 4000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0001'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 5000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 2000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '1111'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 3000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
    G_WA_DATA-AMOUNT = 4000.
    APPEND G_WA_DATA TO G_IT_DATA.
    G_WA_DATA-PROFIT = '0002'.
    G_WA_DATA-COMPANY = '2222'.
    G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
    G_WA_DATA-AMOUNT = 5000.
    APPEND G_WA_DATA TO G_IT_DATA.
    SORT G_IT_DATA BY PROFIT COMPANY ACCOUNT.
    WRITE: /6 'ProfitCenter', 20 'CompanyCode',
    34 'Glaccount', 48 'Amount'.
    WRITE: /6 SY-ULINE(50).
    LOOP AT G_IT_DATA INTO G_WA_DATA.
    AT NEW PROFIT.
    WRITE: /6 G_WA_DATA-PROFIT.
    ENDAT.
    G_AMOUNT = G_WA_DATA-AMOUNT.
    AT NEW ACCOUNT.
    WRITE: /34 G_WA_DATA-ACCOUNT,
    48 G_AMOUNT.
    ENDAT.
    G_SUM_PROFIT = G_SUM_PROFIT + G_WA_DATA-AMOUNT.
    G_SUM_COMPANY = G_SUM_COMPANY + G_WA_DATA-AMOUNT.
    AT END OF COMPANY.
    WRITE: /20 G_WA_DATA-COMPANY,
    34 'Totle',
    48 G_SUM_COMPANY.
    CLEAR G_SUM_COMPANY.
    WRITE: /6 '*******'.
    ENDAT.
    AT END OF PROFIT.
    WRITE: /6 G_WA_DATA-PROFIT,
    20 'Totle',
    48 G_SUM_PROFIT.
    CLEAR G_SUM_PROFIT.
    WRITE: /6 '*************************************'.
    ENDAT.
    ENDLOOP.
    Please use temporary Variable and clear that variable after processing
    Reward Points if it is useful
    Thanks
    Seshu

  • How to calculate the individual sums of multiple columns in a single query

    Hello,
    Using Oracle 11gR2 on windows 7 client. I have a question on calculating sum() on multiple columns on different columns and store the results in a view. Unfortunately I could not post the problem here as it keeps on giving error "Sorry, this content is not allowed", without telling where or what it is! So I had to post it in the stack-overflow forum, here is the link: http://stackoverflow.com/questions/16529721/how-to-calculate-the-individual-sums-of-multiple-columns-in-a-single-query-ora
    Will appreciate any help or suggestion.
    Thanks

    user13667036 wrote:
    Hello,
    Using Oracle 11gR2 on windows 7 client. I have a question on calculating sum() on multiple columns on different columns and store the results in a view. Unfortunately I could not post the problem here as it keeps on giving error "Sorry, this content is not allowed", without telling where or what it is! So I had to post it in the stack-overflow forum, here is the link: http://stackoverflow.com/questions/16529721/how-to-calculate-the-individual-sums-of-multiple-columns-in-a-single-query-ora
    Will appreciate any help or suggestion.
    ThanksLooks like you want a simple group by.
    select
              yr
         ,      mnth
         ,      region
         ,     sum(handled_package)
         ,     sum(expected_missing_package)
         ,     sum(actual_missing_package)
    from test
    group by
         yr, mnth, region
    order by      
         yr, mnth, region;I wouldn't recommend storing your data for year / month in 2 columns like that unless you have a really good reason. I would store it as a date column and add a check constraint to ensure that the date is always the first of the month, then format it out as you wish to the client.
    CREATE TABLE test
         year_month                              date,
        Region                     VARCHAR2(50),
        CITY                       VARCHAR2(50),             
        Handled_Package            NUMBER,       
        Expected_Missing_Package   NUMBER,   
        Actual_Missing_Package     NUMBER
    alter table test add constraint firs_of_month check (year_month = trunc(year_month, 'mm'));
    ME_XE?Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
      2  Values (to_date('2012-nov-12', 'yyyy-mon-dd'), 'Western', 'San Fransisco', 200, 10, 5);
    Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
    ERROR at line 1:
    ORA-02290: check constraint (TUBBY.FIRS_OF_MONTH) violated
    Elapsed: 00:00:00.03
    ME_XE?Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
      2  Values (to_date('2012-nov-01', 'yyyy-mon-dd'), 'Western', 'San Fransisco', 200, 10, 5);
    1 row created.
    Elapsed: 00:00:00.01
    ME_XE?select
      2        to_char(year_month, 'fmYYYY')    as year
      3     ,  to_char(year_month, 'fmMonth')   as month
      4     ,  Region
      5     ,  CITY
      6     ,  Handled_Package
      7     ,  Expected_Missing_Package
      8     ,  Actual_Missing_Package
      9  from test;
    YEAR         MONTH                REGION                         CITY                    HANDLED_PACKAGE EXPECTED_MISSING_PACKAGE ACTUAL_MISSING_PACKAGE
    2012         November             Western                        San Fransisco                       200                       10                      5
    1 row selected.
    Elapsed: 00:00:00.01
    ME_XE?Then you have nice a nice and easy validation that ensures you data integrity.
    Cheers,

Maybe you are looking for

  • How to install iTunes 11.4 back?

    A few days ago I made the foolish mistake of "upgrading" (if you can say that) to iTunes 12 on my MacBook Pro (with OS X 10.8.5) and now I am in the biggest remorse... iTunes 12 is horrible, lacks of sidebar and make sync with iPhone / iPad a real ni

  • JAR File for Channel-Class for Adapter-Modules

    Hello, does anybody know which JAR and Package i need for the Channel-Class. It's not: com.sap.aii.mapping.lookup.Channel I need this one with the method "getValueAsString" in order to write an Adapter-Module. Gunnar

  • ITunes is only playing about 1 1/2 minutes of my songs

    I don't really like the new iTunes.  I was comfortable with the old.  And now, when I try and play my purchased songs, they only play for about 1 1/2 minutes.  And I can't redownload them because I get the you have already downloaded these songs mess

  • Background Transparency of a W3D

    OK, I have a program where I need the background of my W3D to be transparent. When I set the DTS to false to make it transparent, it lags enough to worry me. So, I thought since my W3D object contains absolutely no animation, I could just use a bitma

  • Upgrade certificate 9i to 10g.

    Hi All, Today i upgrade my oracle 9i OCP certificate to Oracle 10g OCP. after complete the 9i OCP, i register in the oracle site, after 45 days i got the certifiacte through courier. now i completed the 10g, kindly tell me how to register for the cer