Calculation in a table

Hi All- I've the following table "Count"
Year        Period               Pd Start Dt    Pd End Dt    Count1         Count2      Count 3
2012    Period 05, 2012    25-APR-12    29-MAY-12    10779455    7557757      0
2012    Period 06, 2012    30-MAY-12    26-JUN-12    11056981    7750255       0
2012    Period 07, 2012    27-JUN-12    24-JUL-12    11328596    7940012        0
2012    Period 08, 2012    25-JUL-12    28-AUG-12    11678538    8182974       0
2012    Period 09, 2012    29-AUG-12    25-SEP-12    11951574    8372835      0
2012    Period 10, 2012    26-SEP-12    23-OCT-12    12228481    8567254       0
2012    Period 11, 2012    24-OCT-12    27-NOV-12    12543681    8789947       0
2012    Period 12, 2012    28-NOV-12    25-DEC-12    12791420    8964870      0 
Now I want to do the following calculation on the table Count3= (Count1/Count2)*100. Can someone please help me with the SQL of this? I know this is pretty straight forward but any help is greatly appreciated. Thanks again.

Hi,
It sounds like you want this:
UPDATE  cnt    -- COUNT is not a good table name
SET     count3  = (count1 / count2) * 100
or, if you don't want to actually change the table:
SELECT  year, period, pd_start_dt, pd_end_dt, count1, count2
,       (count1 / count2) * 100    AS count3
FROM    cnt     -- COUNT is not a good table name
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
If you're asking about a DML statement, such as UPDATE, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002#9362002

Similar Messages

  • Calculation operations on table

    Hi all,
    Is there any way to identify calculation operation on column of table in CREATE TABLE statment. the arguments of operation it will take it from other table columns using SQL.
    e.g: x=y+z where y in table A and z in table B
    please help.
    regards,
    Mona

    As William was noting, you can do a calculation form more than one table at the time you create the table. But, those values in your new tbale will not change if the values in table_A and table_B (which were used in the calculation) change later.
    Maybe you were asking about another feature, new for 11g, whch allows you to create a virtual column. It permits you to create a column in a table which is entirely dependent on one or more other columns in the same table. When the values in those dependent coloumn(s) change, the virtual column changes, too. But: a virtual column can be based only on fields in the same table - you cannot reference other tables in the calculation.

  • Percentage calculation in pivot table per row

    Hello all,
    I do calculate two fields in a pivot table. First calculated field is the # of activities per user (standard SoD reporting field). Second calculated field is the # of activities per user with a certain classification (customized pick list field that is converted in a from a text value to a integer value ==> CASE WHEN Activity.Type = 'Call' THEN 1 ELSE 0 END).
    In the pivot table I do show both vlaues as a sum. I would like to calculate the percentage per row per user.
    Example:
    User - # activities - # calls - percentage
    User XY - 80 - 40 - 50%
    Thanxs for your help
    Elmar

    have you # Call column look like
    sum(CASE WHEN Activity.Type = 'Call' THEN 1 ELSE 0 END) -- column2
    create the percentage column with # activities / column2
    under the column property of the percentage column --> Data Format -->Treat Numbers As --> percentage.
    leave the Aggregation Role as default on all columns.
    Hopefully, I didn't miss anything.
    Shilei

  • F.47 Interest calculation on which table these values will be store

    Hi Team,
    I have query regarding Vendor arrear interest calculation after executing the f.47 it will save in sessions but before executing the session i want the print the form. For this purpose i want information after executing the f.47 these values are stoerd in which table kindly help me on this.
    Thanks and Regards,
    Nauma.

    Hi,
    For every tranasaction code there will be different tables related to that ,so the valuse will be stored in different tables.
    These are the tables releated to This tcode are
    t056,  t056d, t056u, kna1, knb1, bsid, bkpf, bseg, bsega, blntab, lfa1, lfb1, bsik,  tcurx, *bseg, *bkpf, itcpo, t033e, ikofi, t005, ttxd, b0sg, t056a, t056b, "T056K, t056p,  t056l, t056t, t047i,
    If you want in detail what are the field inserted in this table and check run this program RFKUZI00 and check here all the tables and fields
    regards,
    Santoshkumar

  • BYTES calculation on Internal table

    Hi Experts,
    How to find out  the BYTES on internal table.
    EG: itab having the single filed as a string and total character is = 9020370.
    Please provide me any functional module or calculation formula.
    Thanks in Advance.
    Raju

    Hi,
    To findout how much memory internal table occupy choose
    1,Goto  2. Display Condition  3,Memory Usage
    Choose change setting to display a window,in which you can use the inernal table button.
    I hope this information is useful to you .
    Thanks and Regards
    Akhilesh Singh

  • Time Calculations in a Table

    I am creating a new timesheet Which uses a table with a add time/remove time buttons.
    The basic table has a Time In row and a Time Out row. In the footer row Itotal each day. That is no problem as i am using the same script I use in other forms.
    The problem occurs is when you click the Add Time button and now another instance of the Time In and Time Out rows are added.
    How do I now calculate that time and add the 2 together. I can add up to an additional 2 instances. Below is my script for just calculating the basic time for Sunday.
    Thanks,
    Craig
    var vTime1 = Times.TimeIn.in1Sun1.rawValue;
      if (vTime1.length == 4 && vTime2.length == 4) {
    var vTime1Minutes = parseInt(vTime1.substring(0, 1))*600 + parseInt(vTime1.substring(1, 2))*60 + parseInt(vTime1.substring(2, 4));
    var  vTime2Minutes = parseInt(vTime2.substring(0, 1))*600 + parseInt(vTime2.substring(1, 2))*60 + parseInt(vTime2.substring(2, 4));
    this.rawValue = (vTime2Minutes - vTime1Minutes)/60;
    var  vTime2= Times.TimeIn.out1Sun1.rawValue;

    Hi,
    This is the forum to discuss questions and feedback for Microsoft Office, I'll move your question to the Power Pivot forum
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlkjpowerpivotforexcel
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    George Zhao
    TechNet Community Support

  • Calculated non-base table field in a tabular form

    I am struggling with creating a non-base table calculated field in a tabular form in ApEx 3.1
    Can you point me in the right direction
    I thought this would be fairly easy to do, but I cant work out how to do it
    Requirements
    1) Tabular Form based on a table with QTY and PRICE columns
    2) TOTAL is a non-base table field, based on QTY * PRICE
    3) If the Qty or Price changes, the TOTAL should be re-calculated
    Example
    QTY   PRICE  TOTAL
    ===    =====  =====
    3       5          15
    10      50         500
    20      3           60
    Environment
    ApEx 3.1, Oracle 10 and Oracle 11 databases
    I recommended to upgrade to a newer version of ApEx but the request was rejected so Im stuck with 3.1

    Thanks, but its not the solution that I am after
    I am looking for a solution that will ...
           1) not require the calculated value TOTAL to be stored in the table
    and 2) re-calculate the TOTAL when I modify the dependent values (QTY and PRICE) before I save the changes to the database
    I am still looking for a solution if anyone can help

  • Calculated field in table

    I have a MySQL table with 3 columns, tid, text1, text2
    I put rowset in sessionbean and edit the SQLstatement like this
    SELECT tID,
    text1,
    text2,
    CONCAT(text1, ' ', text2) AS "totaltext"
    from testtable
    and runs the query.
    Creator gives a errormessage about not beeing able to view graphicly,
    but allow me to execute and views the result correctly, but without the
    columnname "totaltext".
    When adding a table on a page and Bind the to Data,
    the calculated column is not available.
    What am I doing wrong?

    Solution
    Use - mysql-connector-java-3.1.12-bin.jar - not the 5.0 beta version
    The query editor in Creator still complains about the "(" but runs the query.
    And now you will find the column alias name "totaltext" when you Bind the data to a table and the correct data is shown running the project.

  • Calculating subtotal in table control

    Hi all my requrement is like this
    I am using one tabbed screen .
    in the last tabbed screen i have used table control in that
    screen there is one requirement so that to  calculate the subtotal as we can do in case of alv reporting by using the subtotal button .
    can anybody help me how to do this .

    HI,
    subtotal_text
    Use
    Output text for subtotals in the grid control if the subtotal criterion (column used by the user for calculating the subtotal) is hidden. In the default setting, the ALV Grid Control outputs the column header of the subtotal criterion and the value to which the subtotal calculated refers.
    Event parameters
    Meaning
    ES_SUBTOTTXT_INFO
    Type LVC_S_STXT
    Structure with information on the subtotal criterion
    EP_SUBTOT_LINE
    Type Ref To DATA
    Reference variable to the inserted subtotal line in the grid control. Columns for which no total was calculated remain set to their initial value.
    E_EVENT_DATA
    Type Ref To CL_ALV_EVENT_DATA
    Attribute M_DATA of this object is a reference to the subtotal text.
    For an overview, see: Events of Class CL_GUI_ALV_GRID
    Example
    You display a table with data of structure SFLIGHT in an ALV Grid Control. We now change the pre-set subtotal text for subtotal criterion plane type of table SFLIGHT :
    Define and implement an event handler method for event subtotal_text . Register this event with SET HANDLER .
    Call a subroutine within this method and pass the event parameters to that subroutine.
    Event parameters ep_subtot_line and e_event_data contain reference variables to generic data type DATA . This is why you must use field symbols in the subroutine:
    FORM method_subtotal_text USING es_subtottxt_info TYPE lvc_s_stxt
                                   ep_subtot_line TYPE REF TO data
                                   e_event_data TYPE REF TO
                                   cl_alv_event_data.
      DATA ls_sflight LIKE sflight.
      FIELD-SYMBOLS: <fs1> STRUCTURE sflight DEFAULT ls_sflight,
                    <fs2>.
      IF es_subtottxt_info-criteria = 'PLANETYPE'.
        ASSIGN ep_subtot_line->* TO <fs1>.
        ASSIGN e_event_data->m_data->* TO <fs2>.
        CONCATENATE es_subtottxt_info-keyword ': '
                    <fs1>-planetype INTO <fs2>.
      ENDIF.
    ENDFORM. " METHOD_SUBTOTAL_TEXT
    Result
    Check your result as follows:
    Calculate the total for a column.
    Calculate subtotals for column plane type .
    Hide column plane type . To do this, use either the standard context menu or a new layout.
    The new text defined is displayed at the beginning of a subtotal line.

  • Calculations using Physical Tables vs Logical Tables

    It's easy to find an example of where you would want to use Logical Tables instead of Physical Tables to create fact columns in the repository. Any measure such as Profit Margin (i.e. Profit / Sales) must be computed in the Logical Tables, so that the division operation occurs after the dimensional aggregations are passed to it from the physical layer. In the example of (Profit / Sales), using Physical Columns returns an incorrect result, because it does the division operation first, then aggregates all of those results into a nonsense value.
    So, is there some type of formula in which the reverse is true, such that using Logical Tables would return an incorrect result, while the Physical Tables would return the correct result?
    If not, then under what circumstances would we want to use the Physical Tables instead of the Logical Tables? Is there some type of formula that performs better with Physical Tables?

    Hi Thomson,
    calculations using physical columns generate fair SQL which wouldn't involve any sub-selects in physical query... and would be fast.
    If you use logical columns by selecting the “Use existing logical columns as the source check box" in rpd, most of the times it generates queries.. with sub-selects (means subqueries)
    Ex: suppose you are calculating a calculation based on 2 columns a, b then
    If you use, Logical columns, the query would be something like...
    *Select D1.C1 + D1.C2*
    *From (select Sum(X) as C1,*
    *Sum(Y) as C2*
    *From FactX) D1*
    *Group by DimY*
    If you use, phyiscal columns for calculation the... the query would be...
    *Select Sum(D1.C1 + D1.C2)*
    *From FactX*
    *Group By DimY;*
    which is much preety and good to query the database... without any difficult..
    For first query... it's using inner queries... so process would be slow...
    +Thanks & Regards+
    +Kishore Guggilla+

  • Add a simple calcul to a table with Personalize menu

    Hi
    is it possible to add a column (Message Styled Text) that will do a simple calculation ((score +50 *10000) /quote total) in an existing table (Personalize "Supplier Summary Table")
    thanks

    Thank you Bernd, but that is only part of the solution.  For example, I do set the Page Layout to 1-page-continuous.  MOST of the time it keeps this setting, but some documents either override that setting, or perhaps it reverts back to a default (maybe with version upgrades?).  The other part is that I always want the menu-bar and toolbar to show up.  Some documents hide these when they open.  I realize that I can hit [F8] and/or [F9] to toggle these, but there are additional settings.  I also want to always have the selection tools available, etc.  Bottom Line: I just want a collection of settings that I can call up with a single, simple shortcut or button, so I don't have to perform multiple steps just to get the tool back to my standard configuration whenever something changes it.

  • Perform Calculation before populate table.

    Hi,
    On selection of record in my master table my child table get populated.
    I want to perform some calculation with the data, which suppose to be populated in my child table after selection of master table.
    This calculation should get executed before populating my child table, so once my child table populate it will come up with calculated data.
    Hope i am able to explain my problem.
    Can anyone suggest me any solution??/
    Jdev version:-- 11.0.03
    Thanks,
    Ramit

    Hi,
    First get the selected Row data of master table in backing bean using
    DCIteratorBinding iter =
    getDCBindingContainer().findIteratorBinding(name);
    Then you can get the current row like this:
    Row currRow=iter.getCurrentRow();
    And the value of the Attribute like this:
    Object attribute = currRow.getAttribute("nameOFAttributeAsInViewObject");
    And then set the value to SOC of child table.If SOC is an dynamic list (i.e not from VO) then u can create list and bind the list to SOC.

  • Block stock calculation from mseg table for any given date.

    I am calculating stock from mseg table for any given date. Not just month end stock or current stock. It could be back date also. It is tallying also with MB5B stock report of that date. Now I have to bifurcate that stock into unrestricted stock, quality stock and block stock.
    I have checked INSMK and ZUSTD field in mseg table, but could not concluded. Should I check movement type wise? Block/ Quality stock could be transferred into unrestricted stock also. That also I have to take care.
    Can anyone clearly explain how the stock type posting takes place in mseg table when goods receipt as block / quality stock and when the same goods transferred in unrestricted stock, what are the reference indication.

    DATA : LIST_TAB TYPE TABLE OF ABAPLIST.
    DATA: BEGIN OF VLIST OCCURS 0,
          FIELD1(5)  TYPE C,
          FIELD2(19) TYPE C,
          FIELD3(16) TYPE C,
          FIELD4(17) TYPE C,
          FIELD5(25) TYPE C,
          FIELD6(24) TYPE C,
          FIELD7(25) TYPE C,
          FIELD8(25) TYPE C,
          END OF VLIST.
    TYPES : BEGIN OF ITAB,
           MATNR(18) TYPE C,
           WERKS(5) TYPE C,
           END_MENGE(20) TYPE C,
           END OF ITAB.
    DATA : ITAB TYPE STANDARD TABLE OF ITAB WITH HEADER LINE,
            WA_TAB TYPE ITAB.
    ----submit command to run mb5b in the background and -
    ----push the data into an internal table -
    " Calling MB5B for displaying the Closing Stock
    SUBMIT RM07MLBD USING SELECTION-SCREEN  '1000'
                    WITH DATUM BETWEEN S_DATE-LOW AND S_DATE-HIGH
                    WITH MATNR IN S_MATNR WITH WERKS IN S_WERKS
                    WITH BWART-LOW = '601' EXPORTING LIST TO  MEMORY
                    AND RETURN.
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        LISTOBJECT = LIST_TAB
      EXCEPTIONS
        NOT_FOUND  = 1
        OTHERS     = 2.
    CALL FUNCTION 'LIST_TO_ASCI'
      EXPORTING
        LIST_INDEX         = -1
      TABLES
        LISTASCI           = VLIST
        LISTOBJECT         = LIST_TAB
      EXCEPTIONS
        EMPTY_LIST         = 1
        LIST_INDEX_INVALID = 2
        OTHERS             = 3.
    LOOP AT VLIST WHERE FIELD1 CS '|'.
    CHECK SY-TABIX GE 4.
    MOVE :  VLIST-FIELD1+1(4) TO ITAB-WERKS,
            VLIST-FIELD2+1(18) TO ITAB-MATNR,
            VLIST-FIELD8 TO ITAB-END_MENGE.
    APPEND ITAB.
    ENDLOOP.
    This is the program to call MB5B and the standard program and use the following settings for the closing stock opening stock and block stock

  • Doing calculations on a table or group of tables

    Table A
    Name          Length
    REDBOX          45
    GREENBOX     67
    YELLOWBOX     89
    PINKBOX          23
    How would I write a query that would count the number of rows in the table
    which is this case is 4 (count* maybe) , add up the four values in length
    (using sum () I think) and then multiply both values together.
    So ( num of rows ) * ( sum (length)) = Result.
    I would like to displat the Result as an extra row but not sure you can do that...

    hi
    SQL> ed
    Wrote file afiedt.buf
    1 select t.table_name,count(column_name)
    2 from user_tables t, user_tab_columns c
    3 where t.table_name = c.table_name
    4* group by t.table_name
    SQL> /
    SQL> /
    TABLE_NAME COUNT(COLUMN_NAME)
    BIN$48zoh9RLRoq/Fj6gXkvdxg==$0 8
    BIN$C0999MpPRjGrEnn4tSnBeg==$0 5
    BONUS 4
    DEPT 3
    DEPTT 3
    DUMMY_T2 2
    EMP 8
    EMP1 8
    EMP2 8
    EMPHIST 8
    EMPLOYEES_TEMP 3
    TABLE_NAME COUNT(COLUMN_NAME)
    EMPPROJ 4
    EROW 1
    LOGIN 2
    PARENT 3
    PR 3
    SAL 2
    SALGRADE 3
    T1 1
    TEST 3
    TSTAMP 1
    USERDATA 4
    TABLE_NAME COUNT(COLUMN_NAME)
    USERDATAUSER 4
    VALID_RANGE 13
    24 rows selected.
    mohammadi
    Message was edited by:
    Mohdidubai52

  • OBIEE calculation betn 2 tables

    I have 2 tables one above another in obiee dashboard.in that thre are 3 columns cl 1. col2 for 2 tables respectively. I want third column to be comman in 2 tables with their seprate total tablewise and grand total altogether like balance sheet
    Thanks in advance
    Edited by: [email protected] on Jun 3, 2010 5:33 AM
    Edited by: [email protected] on Jun 3, 2010 5:34 AM

    two tables means two requests joining by union request?
    if so ref here
    how to Make a report from two cubes

Maybe you are looking for

  • How to determine SAP GUI Logon type during runtime?

    Hello All, I have a requirement to detect the SAP GUI Logon type (GUI for Windows vs. GUI for Java) during the execution of a program. Is this possible? Perhaps it would be easier to detect the type of machine; PC vs. Mac ? Any help would be apprecia

  • Emailing Reports to the email address stored for the user in OID?

    Hi I have what seems like a simple enough question. We have an Oracle Forms / Reports Application running on IAS 10.1.2.2.0 on Windows. We use Single Sign On for Forms and Reports. We generate reports from forms using RUN_REPORT_OBJECT. I want to be

  • Problem with update method

    import java.awt.*; import java.applet.Applet; public class graphplotter extends Applet public void init() repaint(); public void update(Graphics g) g.drawRect(0,100,100,100); g.drawLine(50,100,50,200); g.drawLine(0,150,200,150); this code above does

  • EBS-R12 Generate XML (with data) from Embedded Data Definition

    Hi I'm new to running XMLP/BIP in EBS. I have found the extensive set of data definitions and templates in EBS and they work great out of the box. I, however, need to make template modifications. To this end, a correctly structured XML data template

  • Setting Acrobat 7 as my default

    I have both Acrobat 5 & Acrobat 7 on my machine. I keep getting 5 as the default in web browsers (safari, firefox, netscape) and when opening .pdf files. How do I force everything over to 7? Note: I have a machine that boots into either OS 9.2 or 10.