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.

Similar Messages

  • 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

  • Minus operations on table

    Hi everyone,
    I am trying to find a way to do minus operations on table. I know this is possible in SQL, but I have yet to find out how to do it in ABAP. Can anyone help?
    What I need to do is the following.
    Let table A = (A,B,C,D,E) and table B = (B,C,E), then A minus B would return (A,D). Is there a function in ABAP for this?
    Thank you very much in advance.
    Philip R. Jarnhus

    hello,
    u can use subqueries:
    http://help.sap.com/saphelp_NW04/helpdata/en/dc/dc7614099b11d295320000e8353423/content.htm
    it is easy, but wrong way to solve your problem. This select will make a lot of calls to your DB.
    better way:
    1) two selects from table 1 and table 2 into two different internal tables.
    define two internal tables in your code. One table should have standard tables type and another hashed tables type with unique.
    2) subtract the result:
    loop at it_1 into ls_1.
      lv_tabix = sy-tabix.
      read table lt_1 transporting no fields with table key column_name =  ls_1-column_name.
    check sy-subrc eq 0.
      delete it_1 index lv_tabix.
    endloop.
    this solution will speed up your application.

  • Example: Calculating Operation Dates

    Hi Gurus,
    http://help.sap.com/saphelp_46c/helpdata/en/7e/d4191b455911d189400000e8323c4f/frameset.htm
    Menu path: Routings > Scheduling Routings > Example: Calculating Operation Dates
    We have an example in SAP library in the above link.
    As per that queue time, setup time and processing time it is taking 10min extra.
    I mean the setup time is 0.5hrs, but as mentioned in the example,the setup start at 09.20 and setup end at 10.00. My doubt is setup end time should be 09.50. Why it is taking 10min extra.
    Please refer to this example in Library and explain why this difference.
    Regards,
    Jejesh

    Dear,
    please refere the example as the Working Time for work Center is 8 hours Which is then reduced to 6 hours after subtracting breaks & Utilization factor it comes as 6 hrs.
    So the Total reduction is 25% this means that all timings will be set by adding 25 % so that they can be set in 8 Hr scale. the 10 min that u are refering is result of that.
    Think & Try to set the Time considering Breaks & Utilization factor for a Problem ur self u will then able to appriciate that example.
    Regards
    samunder singh

  • IW31/32 Operation User Status visible as a field on  Operation tab table

    Hello,
    Is there a way to add the "Operation User Status" as a field visible on the Operation tab table for IW31/32.
    Your help will be very much appreciated.
    Thanks.

    jay23r 
    Not as standard.. and its the same with the used-fields which should be displayed on the Operation tab table (it is in the task list..)
    I don't know why SAP haven't sorted these out...
    Open an OSS Message to SAP - the more requests they get, the more chance there is of them fixing it in the future
    What we have done a few times in the past is to utilise the Header Enhancement tab (user-exit IWO10018) to add a table control to show these fields. Its not elegant, but it works
    PeteA

  • JAVA operator precedence table is wrong.

    I can not understand why JAVA auto-increment/decrement operator does not follow the rules of Operator Precedence table at http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html
    The precedent order is as follow:
    postfix: expr++ expr--
    unary: ++expr --expr +expr -expr ~ !
    multiplicative: * / %
    From the above we know that x++/x-- is higher then ++x/--x and multiplicative is the lower then both.
    I tested the following in JAVA:
    int y,x = 2;
    y = --x * x++;
    System.out.println(x); //Output is 1.
    Why?
    Theoretically, x++ must be performed before --x, finally then the multiplication (*) and the answer should be
    x++ value=2, stored variable=3
    --x value=2, stored variable=2
    Therefore 2 * 2 = 4.
    Why JAVA is not following the rules that it setup for itself??
    After much research, my conclusion is JAVA Operator Precedence table in java.sun.com website is wrong. The right version should be the same as this website: http://www.sorcon.com/java2/precedence.htm.
    Please run your example code in JAVA before you want to prove me wrong.
    Thank you.

    Hi jsalonen, thank you for your reply. Yes, I see your theory but sorry to say that I don't agree with you. Let's take your example -x++ for our discussion below:
    First let's agree with this:
    x = 2;
    y = -x;
    System.out.println("y = " + y); // y = -2
    System.out.println("x = " + x); // x = 2
    From the above, we can see that by using the negation operator doesn't mean that we have changed the value of x variable. The system just assigns the value of x to the expression but still keeping the value of variable x. That's why we got the output above, agree?
    Now, let's evaluate your example:
    int y, x = 2;
    y = -x++;
    System.out.println("y = " + y); // -2
    System.out.println("x = " + x); // 3
    Hence below is the sequence of process:
    1. -x is evaluated first. Value in variable x is assigned to the expression. At this point the value of x is 2 and this value get negated. However the variable x still storing 2.
    2. Now x++ get evaluated, since this is a postfix increment operator, the value will get assigned first then increase. However x is already assigned, we can not assign it twice, just like if you perform x++ first, you have assigned x then increase and you didn't assign it again for the negation operator. If you did, x would be 3 and get negated to -3. Note that system also cannot perform 2++ because 2 is not a variable. Therefore it is logical to say that x is assigned to the expression and got negated by negation operator then increase the varaible x by 1. So here we increase the value of x by 1 and the result is 3. Therefore variable x is storing 3.
    Now, try the follwing
    x = 2;
    y = -x + x++;
    What is the value of x after -x? It's 2. Remember 2 is assign back to expression but x still retained the original value. If not we would expect x++ to be (-2)++, right?
    But see the output for yourself:
    System.out.println("y = " + y); // 0
    System.out.println("x = " + x); // 3
    As for the subexpression theory, sorry to say that I don't agree with you as well. See the expression below:
    y = -x + x++;
    We can identify that there are 4 operators in this statement, right? (assignment operator, negation operator, addition operator and increment operator)
    since JAVA has defined all the operators in the table and already given each of them a priory and associativity, I don't see any subexpression here. If yes why didn't they mention about subexpression rule in the table? Shouldn't that be defined explicitly so that it doesn't confuse people?
    In conclusion, I still think that JAVA need to correct the operators precedence table at http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html so that they don't confused people for another 10 years. :) Moreover the table is not complete because it did not include . and [ ] and (params) operators.

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

  • WCF-SQL table operation on tables with the same name.

    Hello,
    My situation involves generating table operation schemas (Insert, Update, Delete, Select) for tables in two different SQL databases.  These tables happen to have the same name.  For the sake of discussion lets call the tables dbo.Customer.  However,
    these tables have different fields in them.  When generating the schemas to be used by BizTalk, they end up as the same message type like so:
    Database1: http://schemas.microsoft.com/Sql/2008/05/TableOp/dbo/Customer#Update
    Database2: http://schemas.microsoft.com/Sql/2008/05/TableOp/dbo/Customer#Update
    To my understanding, I can't simply change the namespaces or root nodes to be unique since this structure is expected by the SQL Adapter (shown here: https://msdn.microsoft.com/en-us/library/dd788023.aspx).  I had a couple thoughts on a solution: 
    Use schema versions to differentiate between the two different table schemas.
    Use a unique namespace and root node for the schemas.  Then, create a custom pipeline component to modify them to the standard as it is sent to SQL server.
    Modify the schema so support both tables with all columns in both tables.
    I don't really like any of these solutions, so I am hoping somebody in the community has run into this situation before and has something better.
    -Richard

    You don't really have to do anything other than make sure the particular message gets routed always to the correct database.
    Having duplicate MessageType's is only a problem if you're relying on the automatic resolution of the XmlDisassembler and that would only be a concern on the Response side.
    To get around that, just create a custom Pipeline with the XmlDisassembler and set the Document Schemas list to only the one for that Port.

  • 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

  • Thread safe operations on table in pl/sql procedure?

    I am developing java application which will be running in N localizations simultaneously, each application will have M threads. Every thread takes an unique ID with status NOT_TAKEN from table Queue and changes its status to TAKEN.
    Problem:
    How to prevent thread from situation like this:
    1. Thread A select first ID with status NOT_TAKEN
    2. In the same time thread B select first (so it will be the same ID which selected thread A) ID with status NOT_TAKEN.
    3. Thread A changes status of ID to TAKEN
    4. Thread B changes status of ID to TAKEN
    After this operation thread A and B are using the same ID.
    What I did:
    I have written pl/sql procedure which lock table Queue in exclusive mode, selects first ID, changes its status to TAKEN and unlocks the table. Because it is lock in exclusive mode so only one thread can run this procedure simultaneously.
    Question:
    How optimally should it be solved, because mine solution prevents from doing all other Updates on Queue table while it is locked, like changing status from TAKEN to OPERATION_DONE so it has performance issue.

    As Centinul has said, you need to lock just one row.
    I would just add NOWAIT to the select statement to let the Java thread go and try again, instead of waiting for the other threads.
    Example: (not tested)
    -- Assuming structure of your QueueTable: ( IDCol is PK , StatusCol is VARCHAR2, ... )
    -- or make it part of the package....
    CREATE OF REPLACE
    FUNCTION updateQueue( nQID QueueTable.IDCol%TYPE) RETURN VARCHAR2 AS
       eLocked EXCEPTION;
       PRAGMA EXCEPTION_INIT(eLocked,-54);
       CURSOR curQueueTable IS SELECT 1 CNTR FROM QueueTable WHERE IDCol=nQID AND StatusCol='NOT_TAKEN' FOR UPDATE OF StatusCol NOWAIT;
       recQueueTable curQueueTable%ROWTYPE;
       cRtn VARCHAR2(1);
    BEGIN
       cRtn := 'Y';
       BEGIN
          OPEN curQueueTable;
          FETCH curBuffSummary INTO recQueueTable;
          CLOSE curQueueTable;
          IF recQueueTable.CNTR IS NOT NULL AND recQueueTable.CNTR = 1 THEN
              UPDATE QueueTable SET StatusCol = 'TAKEN' WHERE IDCol=nQID;
          ELSE
              -- Already updated
              cRtn := 'N';
          END IF;
             -- You can control your transaction here as well
             -- COMMIT;
             -- But if realy should be done in the Java thread.
        EXCEPTION
           WHEN eLocked OR STANDARD.TIMEOUT_ON_RESOURCE THEN
           -- Thread could not get exclusice row lock. Ignore error.
             cRtn := 'N';
             NULL;
          WHEN OTHERS THEN
             -- Handle other errors...
             -- NULL; just kidding...
             RAISE;
       END;
       RETURN cRtn;
    END; Edited by: thomaso on Sep 18, 2009 10:30 AM

  • Erratic behaviour map operation after table comparison

    BODI XIR2 11.7.3.6
    We want to detect and store changes in source data and store these changes in the target table.
    After the table comparison the row has got an update operation code flag and goes to a Map operation that converts Update row types to Normal and discards all other row types.
    normal -> discard
    update -> normal
    insert -> discard
    delete -> discard
    The map operation behaviour is erratic: sometimes the update row is mapped to normal and sometimes the update is discarded.

    I would be surprised if that is the case. You could run the dataflow in debug mode, 'cause there you can see the data and the OPCode flag of insert/update/delete after the TC transform.

  • 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

  • How to perform operations on table control

    hello experts,
                         will u plz tell me how to perform operations like delete and update on tablecontrol in module pool.
                                thanks in advance,

    Hey Aravind,
    In case you want to delete just from your table control and not from database table, then you can use the commands:
    clear <workarea_name>
    delete <workarea_name>
    for your selected rows.
    And for deleting from database tables also, use:
    Delete from <Database_table_name> where <where_clause>.
    clear <workarea_name>
    delete <workarea_name>
    This will delete both from the table control and database table also.
    Reward if it proved useful to you.
    Regards
    Natasha Garg

  • DML operations on table

    Hi,
    I need to find which all procedures/function/package performs particular operation on a table.
    Like, if table is SCOTT.EMP, need to find which all objects insert data into it / or delete from it / or updates it.
    Is there any views available for this? or what can be done to get this details.
    Thanks!

    bLaK wrote:
    Thanks jgarry, u understood correct.
    We don't want to do logging or auditing, we just need to find which all objects do insert to particular tables.(this is needed for some performance and benchmark activities) Usually a query to user_source could help to find, but it may not work if there are newline or extra spaces in SQL statement in object.
    Not all DML statements that operate against the DB reside within the DB.
    SQL can reside in OS files external to the DB.
    I know only 3 way to ensure all DML is "captured"
    1) REDO log files
    2) SQL_TRACE files; assuming every session is traced.
    3) AUDIT
    Edited by: sb92075 on Dec 21, 2011 8:21 PM

Maybe you are looking for

  • Creative Cloud wont open or install

    I'm running a 64 bit windows 8 Alienware 17 and I'm had the program for about 6 months now. I admit I havent used the desktop program much, instead just pinning photoshop etc to my task bar. But my school required me to download another app from the

  • ITunes/iPod Nano Problem?

    I recently purchased a refurbished iPod Nano 4th generation from GameStop. When I went to sync the iPod with iTunes, it proceeds to tell me that it is installing "Natrual Voice Text to Speech Reader Standard". After a moment, it shows this - When I c

  • Setting Up an ODBC Data Source in Windows XP for PostgreSQL Unicode

    Can someone help me setup an ODBC data source for a PostgreSQL Unicode database? 1.  Under which tab(s) should I setup the Data Source:  User DSN, System DSN, File DSN? 2.  The check boxes on Advanced Options Pages 1 and 2, which should be checked? I

  • I cant tranfer my IPhone contacts to my mac anymore

    I was looking at my contacts on my mac and I notice that there is no new  contacts from the past two months , I tried backing up my iphone with icloud  but it didnt work,  still the same . How could i transfer my iphone contacts to my mac again ??

  • Anyone have a problem returning one with stuck pixels?

    I have about 5 stuck pixels on mine. I am deciding if I should bring it back or not. Has anyone returned it for that reason? Did you have a problem?