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.

Similar Messages

  • MINUS operation with remote table

    Hi all,
    Please help me with this problem.
    I have two tables with 20 columns each, one table resides on one database and the other table is accesed through a db link. Both tables contains +800,000 records.
    I need to know the record differences between these two tables - this is a periodical process, not for once- , I am using a MINUS operation with full scan, the problem is that my query is taking long time to finish : +20 min. Also i tried witn COLUMN IN() instead MINUS but my query performance is worst.
    Do you know another way to get the record differences with a better performance?
    Thanks in advance
    Edited by: Osymad on Jun 18, 2012 5:12 PM

    Osymad wrote:
    Hi all,
    Please help me with this problem.
    I have two tables with 20 columns each, one table resides on one database and the other table is accesed through a db link. Both tables contains +800,000 records.
    I need to know the record differences between these two tables - this is a periodical process, not for once- , I am using a MINUS operation with full scan, the problem is that my query is taking long time to finish : +20 min. Also i tried witn COLUMN IN() instead MINUS but my query performance is worst.
    Do you know another way to get the record differences with a better performance?
    Thanks in advance
    Edited by: Osymad on Jun 18, 2012 5:12 PMhttp://www.oracle.com/technetwork/issue-archive/2005/05-jan/o15asktom-084959.html
    Search for "Comparing the Contents of Two Tables"
    Cheers,

  • Minus operator versus 'not exists' for faster SQL query

    Hi everybody,
    Does anyone know if rewriting a query to use the MINUS operator instead of using NOT EXISTS in the query is faster, giving all else is the same?
    Thanks very much!
    Bill Loggins
    801-971-6837
    [email protected]

    It really depends on a bunch of factors.
    A MINUS will do a full table scan on both tables unless there is some criteria in the where clause of both queries that allows an index range scan. A MINUS also requires that both queries have the same number of columns, and that each column has the same data type as the corresponding column in the other query (or one convertible to the same type). A MINUS will return all rows from the first query where there is not an exact match column for column with the second query. A MINUS also requires an implicit sort of both queries
    NOT EXISTS will read the sub-query once for each row in the outer query. If the correlation field (you are running a correlated sub-query?) is an indexed field, then only an index scan is done.
    The choice of which construct to use depends on the type of data you want to return, and also the relative sizes of the two tables/queries. If the outer table is small relative to the inner one, and the inner table is indexed (preferrable a unique index but not required) on the correlation field, then NOT EXISTS will probably be faster since the index lookup will be pretty fast, and only executed a relatively few times. If both tables a roughly the same size, then MINUS might be faster, particularly if you can live with only seeing fields that you are comparing on.
    For example, if you have two tables
    EMPLOYEE
    EMPID      NUMBER
    NAME       VARCHAR2(45)
    JOB        VARCHAR2(45)
    HIRE_DATE  DATE
    and
    RETIREE
    EMPID      NUMBER
    NAME       VARCHAR2(45)
    RET_DATE   DATEIf you wanted to see if you had retirees that were not in the employee table, then you could use either MINUS or NOT EXISTS (or even NOT IN, but you didn't ask). However you could possibly get different results.
    SELECT empid,name
    FROM retirees
    MINUS
    SELECT empid,name
    FROM employeeswould show retirees not in the emp table, but it would also show a retiree who had changed their name while retired. A safer version of the above using MINUS would be
    SELECT empid,name
    FROM retirees
    WHERE empid IN (SELECT empid
                    FROM retirees
                    MINUS
                    SELECT empid
                    FROM employees)A full scan of retirees, a full scan of employees (Assuming indexes on both, then maybe an index fast full scan) and two sorts for the minus, at best an index probe then table access by rowid on retirees, possibly a full scan of retirees for the outer query.
    Assuming that employees is indexd on empid then
    SELECT empid,name
    FROM retirees
    WHERE NOT EXISTS (SELECT 1
                      FROM employees
                      WHERE retirees.empid = employees.empid)requires a full scan of retirees and an index access into employees index for each row.
    As with most things SQL, the only real way to tell is to benchmark.
    HTH
    John

  • Minus operator abnormal behavior question

    Oracle 10gR2/Oracle 11g on Windows 2003 R2 32-bit
    There is a very weird query with minus, it is basically:
    select id from table1 where xxxx  --> query 1
    minus
    select id from table1 where xxxx  --> query 2the queries are against the same table, only difference is the where clause. There are 3rd party implemented type and index being used in the where clause in both queries.
    query 1 returns 100 records (i.e. all the records in table1), query 2 returns 0 record.
    but with the minus operator, it returns 1 record.
    If I modify query 2, remove the 3rd party type/index, use another filter that will return 0 record too, then the minus query returns 100 records correctly.
    If I modify the whole query to use not in/not exist instead of minus, then query returns 100 records correctly.
    Question: is it possible the 3rd party type/index can cause the minus operator to behave this way?
    Edited by: modeler on Nov 18, 2009 3:15 PM
    Edited by: modeler on Nov 18, 2009 3:16 PM

    Is there any way you can put together a representative test case that we can test here?

  • MINUS operator fetches invalid record count

    Hi,
    One of the application team complained that oracle MINUS operator fetches an invalid record count after data load.
    Here are the details of the data load:
    They are using source as PROD and target as UAT.
    They are replicating the data on UAT environment in schema A from fetching the data in PROD from the same schema.
    After load when we query the count of records in UAT it shows more records in target, that is in UAT, than PROD.
    When they use MINUS operator to fetch the extra records in UAT, it shows no rows selected.
    SQL> select 'A' count(1) from A.UAT union all select 'A' count(1) from A.PROD@BISLSPD1;
    A COUNT(1)
    A.UAT 19105022
    A.PROD 19104995
    SQL> select distinct count(*) from (select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.UAT minus select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.PROD@BISLSPD1);
    COUNT(*)
    0
    SQL> select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.UAT minus select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.PROD@BISLSPD1
    no rows selected
    Please note that both are partitioned tables and they are using Informatica Data Replication 9.5 tool to populate the data from source to target.
    Not sure if this could be a bug or an issue.
    PROD DB Version: 10.2.0.5
    UAT DB Version: 10.2.0.5
    Both are in Linux 2.6
    Please throw some light on this.

    974065 wrote:
    SQL> select 'A' count(1) from A.UAT union all select 'A' count(1) from A.PROD@BISLSPD1;
    A                  COUNT(1)
    A.UAT                     19105022
    A.PROD                   19104995
    SQL> select distinct count(*) from (select distinct  DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.UAT minus select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.PROD@BISLSPD1);
    COUNT(*)
    0
    SQL> select distinct  DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.UAT minus select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.PROD@BISLSPD1
    no rows selected
    Given that you've go "distinct" in your query, you're eliminating duplicates from each table (and MINUS implicitly means distinct anyway). Check for duplicates (of dw_discount_key, dw_discount_modifier_key) in both tables.
    If the combination is actually unique, I would check that you actually had the raw results the right way round - MINUS is not symmetrical, and for a complete picture you need to look at (select from uat minus select from prod) union all (select from prod minus select from uat)
    Regards
    Jonathan Lewis

  • Error while doing MINUS operation

    Hi ,
    i am using MINUS operation.I am getting the error
    *State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 59019] All of the input streams to the Union operator should have an identical number of columns and union compatible data types. (HY000)*
    I used same data type and i checked with rpd also its working fine.Where is the problem .Can any one help me out??
    Thanks,
    Saichand.V

    hi,
    Thanks for u quick response
    Those are from two Different tables.in Fx i didn't used any operations.Just pulled certain columns.one column is prompted in both the reports.

  • Error using minus operator

    table a
    =========
    id (number),name varchar2,dt date
    10,'aaa','01-01-2006'
    11,'bbb','01-01-2007'
    table b
    ======================
    id varchar2,name varchar2,dt varchar2
    '10','aaa','01-01-2006'
    is it possible to find out which row is not in table b but it is in table a
    i have tried out using minus operator but it return error (ora-01790-expression must have same datatype.

    ora-01790-expression must have same datatypeAnd what is it precisely is it about that error message which is confsuing you?
    SQL> select 1 from dual
      2  minus
      3  select dummy from dual
      4  /
    select 1 from dual
    ERROR at line 1:
    ORA-01790: expression must have same datatype as corresponding expression
    SQL> select to_char(1) from dual
      2  minus
      3  select dummy from dual
      4  /
    T
    1
    SQL> Cheers, APC

  • Instead of Minus operation any other ?

    Hi,
    Master Table : book_master
    Master_Pk_No Book_Name Version_no I_User Initial_id
    10 Book1 0 XXX 10
    20 Book1 1 XXX 10
    30 Book1 2 XXX 10
    # Initial id will be same as Master_Pk_No first number
    # I have to take the latest version ( 2 ) and compare with the older version if any records
    are availble in older version i have to fetch that and append that with the
    Child Table : source
    C_PK_NO SEQ_SOURCE UNIT_SEQ O_User
    10 1 1 XXX
    10 2 1 abc
    10 3 2 abc
    10 4 1 ggg
    10 5 2 ggg
    10 6 3 abc
    10 7 4 abc
    20 1 1 XXX
    20 2 1 abc
    20 3 2 abc
    20 4 1 ggg
    20 5 2 ggg
    20 6 1 zzz
    30 1 1 XXX
    30 2 1 abc
    30 3 2 abc
    30 4 1 ggg
    30 5 2 ggg
    30 6 2 XXX
    SELECT seq_source, o_user, unit_seq
    FROM SOURCE
    WHERE c_pk_no IN ( SELECT master_pk_no FROM AER
    WHERE book_name = 'Book1'
    AND version_no = 0 )
    MINUS
    SELECT seq_source, o_user, unit_seq
    FROM SOURCE
    WHERE c_pk_no IN ( SELECT master_pk_no FROM AER
    WHERE book_name = 'Book1'
    AND version_no = 2) ;
    If i execute this query i will get the below result .
    C_PK_NO SEQ_SOURCE UNIT_SEQ O_User
    10 6 3 abc
    10 7 4 abc
    SELECT seq_source, o_user, unit_seq
    FROM SOURCE
    WHERE c_pk_no IN ( SELECT master_pk_no FROM AER
    WHERE book_name = 'Book1'
    AND version_no = 1 )
    MINUS
    SELECT seq_source, o_user, unit_seq
    FROM SOURCE
    WHERE c_pk_no IN ( SELECT master_pk_no FROM AER
    WHERE book_name = 'Book1'
    AND version_no = 2) ;
    C_PK_NO SEQ_SOURCE UNIT_SEQ O_User
    20 6 1 zzz
    is it possible to achieve this without minus operation ?
    Regards,
    KBG.

    And here is the test:
    SQL> WITH BOOK_MASTER AS(
      2                      SELECT 10 master_pk_no,'Book1' book_name,0 version_no,'XXX' i_user,10 Initial_id from dual union all
      3                      SELECT 20,'Book1',1,'XXX',10 from dual union all
      4                      SELECT 30,'Book1',2,'XXX',10 from dual
      5                     ),
      6           SOURCE AS (
      7                      SELECT 10 c_pk_no,1 seq_source,1 unit_seq,'XXX' o_user from dual union all
      8                      SELECT 10,2,1,'abc' from dual union all
      9                      SELECT 10,3,2,'abc' from dual union all
    10                      SELECT 10,4,1,'ggg' from dual union all
    11                      SELECT 10,5,2,'ggg' from dual union all
    12                      SELECT 10,6,3,'abc' from dual union all
    13                      SELECT 10,7,4,'abc' from dual union all
    14                      SELECT 20,1,1,'XXX' from dual union all
    15                      SELECT 20,2,1,'abc' from dual union all
    16                      SELECT 20,3,2,'abc' from dual union all
    17                      SELECT 20,4,1,'ggg' from dual union all
    18                      SELECT 20,5,2,'ggg' from dual union all
    19                      SELECT 20,6,1,'zzz' from dual union all
    20                      SELECT 30,1,1,'XXX' from dual union all
    21                      SELECT 30,2,1,'abc' from dual union all
    22                      SELECT 30,3,2,'abc' from dual union all
    23                      SELECT 30,4,1,'ggg' from dual union all
    24                      SELECT 30,5,2,'ggg' from dual union all
    25                      SELECT 30,6,2,'XXX' from dual
    26                     )
    27  SELECT  s.seq_source,
    28          s.o_user,
    29          s.unit_seq
    30    FROM  SOURCE s,
    31          BOOK_MASTER a
    32    WHERE s.c_pk_no = a.master_pk_no
    33      AND a.book_name = 'Book1'
    34      AND a.version_no IN (0,2)
    35    GROUP BY s.seq_source,
    36             s.o_user,
    37             s.unit_seq
    38    HAVING MAX(a.version_no) = 0
    39  /
    SEQ_SOURCE O_U   UNIT_SEQ
             6 abc          3
             7 abc          4
    SQL> WITH BOOK_MASTER AS(
      2                      SELECT 10 master_pk_no,'Book1' book_name,0 version_no,'XXX' i_user,10 Initial_id from dual union all
      3                      SELECT 20,'Book1',1,'XXX',10 from dual union all
      4                      SELECT 30,'Book1',2,'XXX',10 from dual
      5                     ),
      6           SOURCE AS (
      7                      SELECT 10 c_pk_no,1 seq_source,1 unit_seq,'XXX' o_user from dual union all
      8                      SELECT 10,2,1,'abc' from dual union all
      9                      SELECT 10,3,2,'abc' from dual union all
    10                      SELECT 10,4,1,'ggg' from dual union all
    11                      SELECT 10,5,2,'ggg' from dual union all
    12                      SELECT 10,6,3,'abc' from dual union all
    13                      SELECT 10,7,4,'abc' from dual union all
    14                      SELECT 20,1,1,'XXX' from dual union all
    15                      SELECT 20,2,1,'abc' from dual union all
    16                      SELECT 20,3,2,'abc' from dual union all
    17                      SELECT 20,4,1,'ggg' from dual union all
    18                      SELECT 20,5,2,'ggg' from dual union all
    19                      SELECT 20,6,1,'zzz' from dual union all
    20                      SELECT 30,1,1,'XXX' from dual union all
    21                      SELECT 30,2,1,'abc' from dual union all
    22                      SELECT 30,3,2,'abc' from dual union all
    23                      SELECT 30,4,1,'ggg' from dual union all
    24                      SELECT 30,5,2,'ggg' from dual union all
    25                      SELECT 30,6,2,'XXX' from dual
    26                     )
    27  SELECT  s.seq_source,
    28          s.o_user,
    29          s.unit_seq
    30    FROM  SOURCE s,
    31          BOOK_MASTER a
    32    WHERE s.c_pk_no = a.master_pk_no
    33      AND a.book_name = 'Book1'
    34      AND a.version_no IN (1,2)
    35    GROUP BY s.seq_source,
    36             s.o_user,
    37             s.unit_seq
    38    HAVING MAX(a.version_no) = 1
    39  /
    SEQ_SOURCE O_U   UNIT_SEQ
             6 zzz          1
    SQL> SY.

  • MINUS Operator in OBIEE 11g

    Hi all ,
    I have a requirement to use MINUS operator in a column of a report . Since it is available for two separate criteria , Could someone suggest how to perform the same in OBIEE 11g for a column.
    the conditions to be implemented in a column are
    select count(*) from ( 
    select distinct trx.shipment_header_id
    from   
    F_ERP_PO_RECEIPTS_TRX trx
    where   trx.transaction_type = 'RECEIVE'
    MINUS
    select distinct rec.shipment_header_id
    from   
    where   trx.transaction_type = 'DELIVER').
    How can i perform these conditions for a column of a report .
    Reg,
    Niv D

    Hi Niv D,
    I guess this can be done as we have union, union all and minus available.
    once you select the required subject area say SA for the below query,
    select distinct trx.shipment_header_id
    from 
    F_ERP_PO_RECEIPTS_TRX trx
    where   trx.transaction_type = 'RECEIVE'
    on the right side of the criteria you can see a + symbol with venn diagram. once you click on it, it gives you an option to select the next SA for
    select distinct rec.shipment_header_id
    from 
    where   trx.transaction_type = 'DELIVER').
    once you selected that, you can see the criteria changes accordingly.
    there you change to union or minus.
    once you have the conditions for both, make the layout as pivot and apply count on the column. you are there with the result,
    I tried earlier with union but not with minus. but this should work.
    Regards,
    KN
    ebs2obiee.wordpress.com

  • The MINUS operator in SQL

    Hi
    i use this minus operator to find the non matching row of the second query.
    after looking at the reasult of this query , i searched the one result in the second query alone i could see the data.
    it's worng The MINUS query returns all rows in the first query that are not returned in the second query.
    in my case it's returning the rows which returned by the second query.
    (select distinct lower(trim(to_char(sso))),lower(trim(to_char(region))),to_date(expiration_date,'DD-MM-YY') from ca_ourc_view
    where rownum <1001
    minus
    (select distinct lower(trim(to_char(sso))),lower(trim(to_char(region))),to_date(expiration_date,'DD-MM-YY') from ourc_members_v1@gesprd
    where rownum <1001
    )thanks
    Raj

    in my case it's returning the rows which returned by the second query.can't happen like this
    for example
    SQL> select * from scott.emp where empno=7369
      2  minus
      3  select * from scott.emp where empno=7499;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20

  • Use of double Minus operator....

    Hi ,
    I have a situation where i need to use the minus operator in such a way that:
    <sql_statement_A>
    Minus
    <sql_statement_B>
    Minus
    <sql_statement_C>
    The resulting row set will return rows from sql_statement_A minus rows from sql_statement_B or sql_statement_A minus rows from sql_statement_C... Is the above sql pattern is correct....or , do i need to write two views
    <sql_statement_A>
    Minus
    <sql_statement_B>
    and
    <sql_statement_A>
    Minus
    <sql_statement_C>
    and one third making Union of the two above...????
    many thanks,
    Simon

    If in doubt, use parentheses to make them run the way you want.
    So..
    (<sql_statement_A>
    minus
    <sql_statement_B>)
    minus
    <sql_statement_C>
    Just like OR conditions in the where clause, grouping with parentheses will greatly help those who come later to maintain it. And this looks simpler and more efficient than using two minus operations and combining the result.

  • 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

  • Using the minus operator

    I am very new to oracle and am working with the minus operator to run a query. I could use some help!
    Here is the query I am working on:
    select suppliername, partname
    from quote
    where partname = 'hammer'
    minus
    select suppliername, partname
    from quote
    where partname = 'hammer';
    HOW DO I GET THE QUERY TO DISPLAY ONLY THE ROWS OF SUPPLIERNAMES THAT SUPPLY ONLY HAMMERS?
    I WOULD GREATLY APPRECIATE SOME CLARIFICATION.

    HOW DO I GET THE QUERY TO DISPLAY ONLY THE ROWS OF SUPPLIERNAMES THAT SUPPLY ONLY HAMMERS?It may, for some data related reason, give you the result you were expecting, but this query does not answer that question because you have included partname in the MINUS.
    E.g.
    WITH quote AS
    (SELECT 'BOB'  suppliername, 'HAMMER' partname FROM DUAL UNION ALL
    SELECT 'BOB'  suppliername, 'SPANNER' partname FROM DUAL UNION ALL
    SELECT 'TIM'  suppliername, 'HAMMER' partname FROM DUAL UNION ALL
    SELECT 'JACK' suppliername, 'HAMMER' partname FROM DUAL)
    SELECT suppliername, partname
    FROM   quote
    MINUS
    SELECT suppliername, partname
    FROM   quote
    WHERE  partname != 'HAMMER';
    SUPPLIERNAME PARTNAME
    BOB          HAMMER  
    JACK         HAMMER  
    TIM          HAMMER   Clearly this is wrong because Bob supplies spanners (aka wrench).
    However:
    WITH quote AS
    (SELECT 'BOB'  suppliername, 'HAMMER' partname FROM DUAL UNION ALL
    SELECT 'BOB'  suppliername, 'SPANNER' partname FROM DUAL UNION ALL
    SELECT 'TIM'  suppliername, 'HAMMER' partname FROM DUAL UNION ALL
    SELECT 'JACK' suppliername, 'HAMMER' partname FROM DUAL)
    SELECT suppliername
    FROM   quote
    MINUS
    SELECT suppliername
    FROM   quote
    WHERE  partname != 'HAMMER';
    SUPPLIERNAME
    JACK        
    TIM          Amongst the many alternatives - NOT EXISTS:
    WITH quote AS
    (SELECT 'BOB'  suppliername, 'HAMMER' partname FROM DUAL UNION ALL
    SELECT 'BOB'  suppliername, 'SPANNER' partname FROM DUAL UNION ALL
    SELECT 'TIM'  suppliername, 'HAMMER' partname FROM DUAL UNION ALL
    SELECT 'JACK' suppliername, 'HAMMER' partname FROM DUAL)
    SELECT *
    FROM   quote q1
    WHERE  NOT EXISTS (SELECT 1
                       FROM   quote q2
                       WHERE  q2.suppliername = q1.suppliername
                       AND    partname != 'HAMMER');
    SUPPLIERNAME PARTNAME
    JACK         HAMMER  
    TIM          HAMMER  

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

  • Minus Operation Obiee

    Hi All,
    I have created a report utilizing the minus operation as follows:
    Person_Wid (Filtered by a set of criteria selected by users via prompts)
    minus
    Person_wid (Filtered by another set of criteria selected by users via prompts)
    I get the correct person_wids.
    However I need to calculate count of the person_wid obtained in the result. Can someone tell me how I can achieve this.
    Thanks

    Hi David,
    Thanks for ur suggestion. However the query I am trying to execute is
    Person_Wid (Filtered by a set of criteria selected by users via prompts) ----->A
    minus
    Person_wid (Filtered by another set of criteria selected by users via prompts)--------->B
    So when I implement what you suggested I get the count of only 'A'. It does not give me the row count of (A-B). Is there something I need to tweak?
    Thanks,
    Nikita

Maybe you are looking for

  • Iphone 5 doesnt display contacts when connected to car

    My Car doesnt display my contacts in my phonebook when connected via blutooth to my car??

  • ORA-6571 ERROR (PACKAGE PRAGMA의 사용)

    제품 : SQL*PLUS 작성날짜 : 1997-06-03 * ORA-6571 Error ( Package Pragma 의 사용 ) ============================================= SQL문 안에서 Stored function을 call하여 사용하는 경우 ORA-6571 error가 발생할 수 있습니다. 기본적으로 stored function이나 procedure, package에서의 DML 문장의 사용은 보장이

  • Print issue... will print, but won'trint something,

    Hi all, I just bought an Epson Stylus NX215. I installed the drivers etc, and everything seemed peachy keen. However, if I go to print something, it comes up with the usual window but when I click "print" it just shows the button being clicked(or dep

  • Enable Extensions not Showing up in Delop Menu

    I have upgraded to Safari and checked "Show develop menu in menu bar". "Enable extensions" does not show in Develop menu. I have searched and tried many suggestions but no luck. Does anyone have an answer? Thank you in advance, Bill

  • E72 WPA PSK handshake problem

    Hi, my company has bought a couple of E72's. I'm trying desperatly to get them to connect to our WLAN network, which is encrypted using WPA/WPA2 with a PSK. Every other device will just work fine, but the E72 is timing out while connecting giving an