Comparing two rows, pair by pair

Ok, this SHOULD be easy, but having tried this about 20 different ways (with the most common error that a range can't be used as a single number), I have given up.
I have 2 rows of numbers. I want to compare the pair of cells in the same column and if my comparison is true for EVERY pair, then the IF is true.
For example:
Header 1
Header 2
Header 3
Header 4
Header 5
Header 6
Header 7
Header 8
20
12
13
15
2
TRUE or 1 or something
20
91
15
29
1
15
3
So, each cell in the top row is less than or equal to the matching cell in the bottom (for the first 7 columns), therefor it is TRUE in Column 8.
For just ONE attempt, I tried =AND(A1:A7<=B1:B7), which of course gives me "The range A1:A7 can't be used as a single number".

Hi Mark,
"Numbers isn't c++, and doesn't do array or matrix calculations."
True enough.
Here's another formula, similar to Wayne's in the amount of work needed to set it up.
=MAX(A2-A3,B2-B3 ,C2-C3 ,D2-D3 ,E2-E3 ,F2-F3 ,G2-G3 )<=0
It assumes the data is all numerical.
Wayne's suggestion to use his second (and simpler) formula 'with caution' is well taken. It's not difficult to show several examples where it will produce wrong results:
Regards,
Barry

Similar Messages

  • Comparing two rows field by field through a loop

    Hi all,
    I've got a tricky issue:
    There are two tables (almost) identically designed;
    In the first one there are lets say some new data and in the 2nd one there is data to be hold & adjusted;
    I built up a third table, which contains the meta informations about the two other tables (i.e. it describes the tables, so for each field of these tables, there is the field name, field type, primary key marker, etc.);
    The challenge now is, how can I compare two rows (of the same primary key) field by field and get out the differences (and adjusting the target table row) using PL/SQL procedures/functions.
    I thought a create a cursor over the 3rd table and call functions to get the fields out (given by the field name of the cursor), compare the two fields and return if it's equal or different...
    As I've seen, there is now direct way to replace a field name in a statement - but how to resolve this with a cool workaround?
    In addition, there are about 120 pairs of such tables, to be compared in the same way - so I decided to prevent creating hard coded design for the software.
    Even the selection of a pair of rows from the two tables should be parameterized, 'cause the primary keys are of course different in the 120 table pairs.
    Any hints or suggestions?
    Thanks in advance & regards,
    Peter

    Hi Peter,
    I am very far from being an expert in Oracle but, everything I've read so far strongly suggests that PL/SQL is often the fastest among the customized solutions (beating even compiled C code). The reason - from what I've understood - is that PL/SQL is part of the Oracle kernel/engine, other languages simply aren't.
    I suggest you do your own research to confirm what I've just said above.
    On a completely different note, when I first read your post, I started writing a reply and decided to discard it because, I figured you probably would find it too far off your original thoughts. However, then you wrote:
    >
    There are some reasons to prevent hard coding, but it may be possible to generate the PL/SQL-code for each pair of tables by an external program.
    >
    This is exactly what I was mentioning in the post I ended up discarding. The basic step by step process I was going to mention is as follows:
    STEP 1: If possible, write one PL/SQL program that does the job properly for one set of tables. Test it thoroughly and identify potential differences in the process if it had to be applied against other tables. Make it as generic as reasonably possible, that is, keeping the code as simple as possible.
    STEP 2: turn the working code of step 1 into a template (usually replacing table names, columns, etc by some token that would not be a valid name).
    STEP 3: generate a list of the tables and their corresponding columns you need to process. This list may need to be massaged a little to become the generating seed of 120 programs (or so based on what you've said).
    STEP 4: if you don't know Perl or AWK then (don't be alarmed...) download AWK (not Perl) and learn it... you can learn the thing in a couple days (maybe even less). It is a very simple and straightforward text processing language, I know non progammers that learned enough in one day to do useful things with it. Using AWK you can easily generate the 120 programs you need from a working template in very little time (a few hours after you've become proficient). By the way, there is AWK, GAWK, NAWK, all pretty much the same thing and all free. The standard manual for AWK is the one written by the authors Aho, Weinberger and Kernigan, about 100 small pages, it's an easy read and no programmer should be without it :) (better than American Express!)
    What you've described sounds just like the thing to use AWK for. I once used AWK to generate 27,000 (that's 27 thousand) lines of COBOL code, debugged and fully tested in 2 days! (testing was automated using AWK too!) It would have taken much longer to just type all that code.
    Anyway, I hope that gives you something to think about and be of some help.
    John.

  • How to compare two rows in PL/SQL?

    Hi All,
    How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?
    Any feedback would be highly appreciated.

    PhoenixBai wrote:
    Hi All,
    How to compare two rows in PL/SQL? Is there any method that I can use instead of comparing them column by column?What "rows" are you referring to?
    If you're talking of rows within a PL/SQL associative array there are techniques as described in the documentation... e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    type v1 is table of number;
      3    r1 v1 := v1(1,2,4);
      4    r2 v1 := v1(1,2,3);
      5  begin
      6    if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
      7      dbms_output.put_line('Same');
      8    else
      9      dbms_output.put_line('Different');
    10    end if;
    11* end;
    SQL> /
    Different
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    type v1 is table of number;
      3    r1 v1 := v1(1,2,3);
      4    r2 v1 := v1(1,2,3);
      5  begin
      6    if r1 MULTISET EXCEPT DISTINCT r2 = v1() then
      7      dbms_output.put_line('Same');
      8    else
      9      dbms_output.put_line('Different');
    10    end if;
    11* end;
    SQL> /
    Same
    PL/SQL procedure successfully completed.
    SQL>If you're talking about rows on a table then you can use the MINUS set operator to find the rows that differ between two sets of data...
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    30
          7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    10
    14 rows selected.
    SQL> select * from emp2;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7521 WARD       SALESMAN        7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-1981 00:00:00       2975                    20
          7782 CLARK      MANAGER         7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17-NOV-1981 00:00:00       5000                    10
          7900 JAMES      CLERK           7698 03-DEC-1981 00:00:00        950                    30
          7934 MILLER     CLERK           7782 23-JAN-1982 00:00:00       1300                    10
    7 rows selected.
    SQL> select * from emp
      2  minus
      3  select * from emp2;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-1981 00:00:00       1600        300         30
          7654 MARTIN     SALESMAN        7698 28-SEP-1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-1981 00:00:00       2850                    30
          7844 TURNER     SALESMAN        7698 08-SEP-1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-1987 00:00:00       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-1981 00:00:00       3000                    20
    7 rows selected.If you actually need to know what columns data is different on "non-matching" rows (based on your primary key) then you'll have to compare column by column.

  • Compare two rows in same table

    Hi,
    I want to compare two rows (some columns) in the same table, and if the data in the data columns is different, I want to pick the latest one. The table is date tracked. For instance I have an address table with different addresses for an employee with effective date. I want to be able to pick the latest row if the postal code is different for the 2 rows. Is this possible in sql. I can do this in Pl/sql, but dont want to use it. Eg
    address_id, postal_code, person_id,last_update_date
    123, pn123,1,12-JAN-01
    124,pu124,1,13-JAN-01
    I want to be able to retrieve just the second line.
    Any help is appreciated

    Welcome to the forum!
    Whenever you post please provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    >
    The table is date tracked. For instance I have an address table with different addresses for an employee with effective date. I want to be able to pick the latest row if the postal code is different for the 2 rows.
    >
    Your question is a little confusing because you are using terms like 'date tracked' and 'effective date' without explaining exactly what your definitions of those terms is.
    Why do you want the latest record ONLY if the postal code is different? What if the address is different? Then which record do you want?
    Why not just take the record for each person/company that has the latest date? If the data is the same then it doesn't which record you get so the one with the latest date will do. And if the data is different taking the one with the latest date gives you the latest data.
    The classic definition of effective date is 'the date the information becomes effective'. Information with a given effective date is NOT in effect before that date and is SUPERCEDED when data is entered with a later effective date if the actual date is later than or equal to the effective date. Using your data
    >
    123, pn123,1,12-JAN-01
    124,pu124,1,13-JAN-01
    >
    The first record IS NOT effective for dates prior to 12-JAN-01. In fact for a query looking for data prior to that date there isn't any data.
    The first record is also NOT effective for dates on or after 13-JAN-01. Only the second record is effective.
    If you added a record for 14-JAN-01 this record would not be effective until on or after that date (i.e. not for another 4 1/2 months).
    So for the classic definition of effective date the query needs to provide the AS OF date to use to obtain the data. If, as in your system, you are not allowed to create records with dates in the future and you just want the latest record then you can just select the record with the MAX(myDate) value for the given person_id, address_id or whatever your key values are.
    Edited by: rp0428 on Aug 11, 2012 7:50 AM

  • Compare two rows in a same table

    Dear all
    I need to compare two rows in the same table, I dont know hoe to do it in pl/sql. Some one please help me on this.
    example:
    tr br price
    xya0001 ama7 12
    xya0003 ama6 14
    xya0004 ama7 16
    in the table tr is a unique value for each row, I need to compare price column and see whether the first value is less or greater than the next value and, if it is greater put the corresponding br value to a variable and if it is smaller put the corresponding br value to another variable. I dont know a method to do it, as I'm new to pl/sql. Some one please help me in this

    not sure what you intend to do as you have mentioned that "TR" is unique and you just want to compare each record with just the next record. Hope below query helps. The value "G" or "L" in flag would indicate if the current records price is greater than or less than the price in next record.
    select tr,br,price,col4, case when price> col4 then 'G'  when price< col4 then 'L' end flag from (
    select tr,br,price,lag(price,1,0) over(order by tr) col4 from testcomp
    )

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • VORowImpl problem - comparing two ROW[] lists

    Hi Everyone,
    I have a huge proble right now, I'm trying to compare two VO list with the same values, this is because one it's attached to an advancedtable in the xml page wich the user can change some values, and the other one is from the values of the table but from the DB, the reason is to made a validation to compare the original values from the DB with the list from the tabla and update only the rows that the users made changes in their values, here's my code for a better explain of what I'm doing:
    public void saveChanges(){
    OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)getDBTransaction();
    Row[] rows1 = getAppVO1().getAllRowsInRange();
    Row[] rows2 = getDBVO1().getAllRowsInRange();
    for(int i = 0; i < rows1.length; i++){
    int j = i;
    //Colections to compare
    //r1: colection from the app
    //r2: colection from BD
    AppVORowImpl r1 = (AppVORowImpl) rows1;
    DBVORowImpl r2 = (DBVORowImpl) rows2[j]; //<--- here in the second iteration appears the following error:
    // "oracle.apps.fnd.framework.OAException: java.lang.ArrayIndexOutOfBoundsException: 1"
    //variables string to check if got changes in the column
    String columnAPP = r1.getId().toString();
    String columnBD = r2.getId().toString();
    //'if' that validates changes
    if(!columnAPP.equals(columnBD)){
    //String variable SP
    StringBuilder procedureCall = new StringBuilder();
    //calling to SP
    try{
    procedureCall.append("... stored proc...");
    OracleCallableStatement oraclecallablestatement = (OracleCallableStatement)oadbtransactionimpl.createCallableStatement(procedureCall.toString(), -1);
    oraclecallablestatement.execute();
    getOADBTransaction().commit();
    }catch(SQLException sqlexception){
    System.err.println("SQL Exception: "+ sqlexception.getMessage());
    getOADBTransaction().rollback();
    throw OAException.wrapperException(sqlexception);
    }catch(Exception e){
    System.err.println("Exception: "+ e.getMessage());
    getOADBTransaction().rollback();
    throw OAException.wrapperException(e);
    the first iteration works fine, but the second and futher shows an exception error, what can I do to make this method works?
    I'll be pending to your answers, I really hope you can help me with this one
    Regards,
    Mentor

    Here is the dump code for you. Code you have to write in AmImpl and call the same from Controller class.
    AMImpl Code
    public void executeBothViewObjects() //Calls this method from Controller *ProcessRequest*
            OAViewObject vo = (OAViewObject)getMainViewObjectVO1();
            OAViewObject dvo = (OAViewObject)getDBViewObjectVO1();
           if (vo != null && dvo != null)
                         //1st VO
                           dvo.setWhereClauseParams(null);
                          //Set where clause if Any  dvo.setWhereClauseParam(0,xx);
                          dvo.executeQuery();  
                         //2nd VO
                         vo.setWhereClauseParams(null);
                          //Set where clause if Any  dvo.setWhereClauseParam(0,xx);
                         vo.executeQuery(); 
    public void compareViewObject()   // Calling this method to compare Attribute of both View Object *Process Form Request*
          OAViewObject vo = getMainViewObjectVO1();
          OAViewObject OrigVO = getDBViewObjectVO1();
          MainViewObjectVORowImpl rowi = null;
          DBViewObjectVORowImpl rowii = null;
          int fetchedRowCount = vo.getRowCount();
          int OriginalfetchedRowCount = OrigVO.getRowCount();  
         RowSetIterator originalSelectIter = OrigVO.createRowSetIterator("originalSelectIter");
         RowSetIterator selectIter = vo.createRowSetIterator("selectIter");
         if (fetchedRowCount > 0 && OriginalfetchedRowCount >0)
              selectIter.setRangeStart(0);
              selectIter.setRangeSize(fetchedRowCount);
              originalSelectIter.setRangeStart(0);
              originalSelectIter.setRangeSize(OriginalfetchedRowCount);
              for (int i = 0; i < fetchedRowCount; i++)
                rowi = (MainViewObjectVORowImpl)selectIter.getRowAtRangeIndex(i);
                rowii = (DBViewObjectVORowImpl)originalSelectIter.getRowAtRangeIndex(i);
               //Compare Attribute here
                   if((!(rowi.getRoleStartDate().equals(rowii.getRoleStartDate()))
                            // Comparing Start date here of both View Object
                 else if(((rowi.getRoleEndDate().equals(rowii.getRoleEndDate()))
                       // Comparing End date here of both View Object
    }Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • How to compare two rows in PL/SQL and retrieve the values?

    Hello,
    I have two tables which have identical schemas, one table (tbl_store) is used to hold the latest version, and the other table (tbl_store_audit) holds previous versions. When the latest record is updated, it is inserted into the tbl_store_audit table as a revision, and the updated details are used as the latest record.
    For example: The latest version is held in tbl_store, however the tbl_store_audit may hold 5 records which are the past records used before changes were made - these are seen as revisions.
    I want to be able to compare what has changed between each revision in the tbl_store_audit table. For example: Out of the 10 columns, the change between revision 1 and revision 2 was the size from XL to XXL. The change between revision 3 and revision 4 was the size XS to M and price 4.99 to 10.99, and so on.
    Eventually i will create an APEX report that will show the user the revision number and what was changed from and to.
    I seen in a previous post i need to note my oracle version: Oracle version 10.2.0.4.0

    Hi,
    Like suggested already you should give some sample data and output.
    Maybe you would like to have something like this:
    -- Sample data
    -- Note PK is the primairy key of the source table and rev are the revisions
    with tbl_store_audit as
    select 1 pk, 1 rev , 1 price  , 'XXL' unit_size from dual union all
    select 1 pk, 2 rev , 1 price,   'XL'  unit_size from dual union all
    select 1 pk, 3 rev , 1.4 price, 'XXL' unit_size from dual union all
    select 2 pk, 1 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 2 pk, 2 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 2 pk, 3 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 1 pk, 4 rev , 1 price  , 'XL'  unit_size from dual union all
    select 1 pk, 5 rev , 1 price  , 'XL'  unit_size from dual union all
    select 3 pk, 1 rev , 1.2 price, 'XL'  unit_size from dual union all
    select 3 pk, 2 rev , 1.2 price, 'XXL' unit_size from dual union all
    select 4 pk, 1 rev , 1 price  , 'XL'  unit_size from dual
    -- end of sample data
    ,tbl_store_audit_tmp as
    select
      pk
      ,rev
      ,'PRICE'          field_name
      ,to_char(price)   field_value
      ,to_char(lag(price,1) over (partition by pk order by rev) ) old_field_value
    from
      tbl_store_audit
    union all
    select
      pk
      ,rev
      ,'UNIT_SIZE'           field_name
      ,to_char(UNIT_SIZE)    field_value
      ,to_char(lag(UNIT_SIZE,1) over (partition by pk order by rev) ) old_field_value
    from
      tbl_store_audit
    -- include all other fields from the table here with it's own union all select ...
    select
    from
      tbl_store_audit_tmp
    where
      field_value != old_field_value
    PK REV FIELD_NAME FIELD_VALUE                              OLD_FIELD_VALUE                       
    1   3 PRICE      1.4                                      1                                       
    1   4 PRICE      1                                        1.4                                     
    1   2 UNIT_SIZE  XL                                       XXL                                     
    1   3 UNIT_SIZE  XXL                                      XL                                      
    1   4 UNIT_SIZE  XL                                       XXL                                     
    3   2 UNIT_SIZE  XXL                                      XL                                      
    6 rows selected If you realy want to keep track of all the changes I think it would be better if you make a "after update trigger" on the base table that checks what changed and put that directly in the uadit table.
    Regards,
    Peter
    Edited by: Peter vd Zwan on Aug 16, 2012 8:25 AM

  • COMPARE TWO ROWS

    I WANT TO COMPARE A SINGLE ENTITY IN A ROW WITH A ENTITY FROM THE OTHER ROW IN A JTABLE.COULD ANY BODY HELP ME OUT.I BEG YOUR PARDON FOR MY ENGLISH.
    Message was edited by:
    DHIRAJKUMAR

    Use getValueAt(). And press your caps-lock key, please.

  • How can i compare two rows

    hi all,
    In my report there is a table with 3 rows. I have to put a direction image at 4th row based on the difference of 2nd and 3rd row.
    can anyone help me?
    Thanks in advance.

    Hi Tanjima,
    In what way you want ot compute the difference between the 2nd and 3rd rows of data?
    It would be of great helps if you paste the report data here and Explain what you want in your rows?
    You can't refer indivisual cell or individual row in WEBI everything you want to do you have to do it using column references.
    Thanks..
    Pratik

  • I would like the row color to alternate in pairs - for example, two rows of grey then two rows of white.  How do I achieve this format?

    I would like the row color to alternate in pairs - for example, two rows of grey then two rows of white.  How do I achieve this format?

    Hi OldRailroadMan,
    Here is one way. Start with a table with no fill (or white).
    Change the fill of the first two rows.
    Select cells in the first four rows.
    Drag the yellow Fill Handle down.
    For some reason this does not work if you select whole rows (by clicking on the row numbers at the left).
    When you are happy with the result, Menu > File > Save As Template.
    Regards,
    Ian.

  • Compare two cells in a row and group of rows

    Tuesdays 1st 2nd 3rd 4th 5th MB
    Jan 4, 2011 7 14 21 28 36 32
    Jan 11, 2011 5 15 25 28 38 16
    Jan 18, 2011 2 17 25 28 38 25
    Okay, say the above is my table, how do I compare two cells in a row for two numbers? Say I wanted to find out if row A2 contained a 7 and a 28?
    I thought an IF formula might do it, but can't figure it out.
    Thanks in advance!
    Jim

    Head Crab wrote:
    Tuesdays 1st 2nd 3rd 4th 5th MB
    Jan 4, 2011 7 14 21 28 36 32
    Jan 11, 2011 5 15 25 28 38 16
    Jan 18, 2011 2 17 25 28 38 25
    Okay, say the above is my table, how do I compare two cells in a row for two numbers? Say I wanted to find out if row A2 contained a 7 and a 28?
    "A2" is an address for a single cell, not a row. Its current content, assuming no empty rows above or empty columns left of what's shown, is "Jan 4, 2011". Perhaps you mean Row 2, or the range B2:G2.
    Assuming that you want to know 'if' (or 'how many times') two specific numbers occur in the range of cells from column B to column G in a single row, COUNTIF is the function you want.
    Place the two target numbers into cell I1 and J1.
    Enter the formula below into I2:
    =COUNTIF($B2:$G2,I$1)
    Fill the formula right into J2, then fill both down to row 4.
    You'll get a count of the occurrences of each number.
    If you want only a "Yes" (both numbers appear in the range) or "No" (neither of the numbers appear, or one appears but not the other), use this variation (in I2 or J2):
    =IF(AND(COUNTIF($B2:$G2,I$1)>0,COUNTIF($B2:$G2,J$1)>0),"Yes","No")
    Regards,
    Barry

  • Compare column data of two rows

    Hi there,
    I a have a table
    COMP_ID      PROD      COLOR       COMPAREFLAG  ORDER_NUMBER
    1           sun      red            -                          2
    2              sun      blue          Y                         2
    3           horse      black         -                          1
    4              horse   white            Y                         1
    5           chair      black          -                         3
    6          chair    black          Y                         3I would like to compare for example the columns PROD and COLOR of two rows with ORDER_NUMBER = 2
    The row with COMP_ID = 1 is the first entry and with COMP_ID = 2 the second one therefore the COMPAREFLAG is set to 'Y'.
    If the entries are diffrent both rows should be return to output.
    I would like to compare also the rows with COMP_ID 5 and 6. In this case nothing should be return to output.
    I don't know how to manage this. Can anyone please help me?
    Thanks,
    ben
    Message was edited by:
    ben512

    I hope that I well understand.
    Do you want to get rows only if PROD/COLOR of one row is different of the PROD/COLOR from other row (with the same order_number) ?
    What you can try :
    SQL> with tbl as
      2  (select 1 comp_id, 'sun'   prod, 'red'   color, null compareflag, 2 order_number from dual union all
      3   select 2 comp_id, 'sun'   prod, 'blue'  color, 'Y'  compareflag, 2 order_number from dual union all
      4   select 3 comp_id, 'horse' prod, 'black' color, null compareflag, 1 order_number from dual union all
      5   select 4 comp_id, 'horse' prod, 'white' color, 'Y'  compareflag, 1 order_number from dual union all
      6   select 5 comp_id, 'chair' prod, 'black' color, null compareflag, 3 order_number from dual union all
      7   select 6 comp_id, 'chair' prod, 'black' color, 'Y'  compareflag, 3 order_number from dual )
      8  select comp_id, prod, color, compareflag, order_number
      9  from  (select comp_id,
    10                prod,
    11                decode(first_value(prod) over (partition by order_number order by comp_id range between unbounded preceding and unbounded following),
    12                       last_value(prod) over (partition by order_number order by comp_id  range between unbounded preceding and unbounded following),null,prod) prod_d,
    13                color,
    14                decode(first_value(color) over (partition by order_number order by comp_id range between unbounded preceding and unbounded following),
    15                       last_value(color) over (partition by order_number order by comp_id  range between unbounded preceding and unbounded following),null,color) color_d,
    16                 compareflag,
    17                 order_number
    18         from   tbl
    19         where  order_number=&order_number)
    20  where  (prod_d is not null or color_d is not null)
    21  order by 1;
    Enter value for order_number: 1
    old  19:        where  order_number=&order_number)
    new  19:        where  order_number=1)
       COMP_ID PROD  COLOR C ORDER_NUMBER
             3 horse black              1
             4 horse white Y            1
    SQL> /
    Enter value for order_number: 2
    old  19:        where  order_number=&order_number)
    new  19:        where  order_number=2)
       COMP_ID PROD  COLOR C ORDER_NUMBER
             1 sun   red                2
             2 sun   blue  Y            2
    SQL> /
    Enter value for order_number: 3
    old  19:        where  order_number=&order_number)
    new  19:        where  order_number=3)
    no rows selected
    SQL> Nicolas.

  • IMX with two stereo pairs audio setting?

    Hello.
    I am trying to build a Compressor preset to export from 1080i ProRes, two stereo pairs, to PAL IMX, same audio setup. I can do it within FCP7 and FCPX, but I'd like to be able to build the Compressor setting as well. So far I can only build the destination file with one stereo pair. Any help?
    Thank you and best regards
    Fabrizio D'Agnano
    Rome, Italy

    OK, I've found a workaround following a tip from Jeremy Garchow at Creative Cow.  If the clip to be converted has the two stereo pairs, you can create your own IMX setting in Compressor choosing "audio pass through" in the audio settings in the inspector window.
    Fabrizio D'Agnano
    Rome, Italy

  • Comparing two elapsed timer readings

    Hi everyone,
    I'm a new user of Labview, so I'm teaching myself as I go along really. I've come up against a problem though. I'm trying to compare two timer readings from elapsed timers. Eventually I am hoping to swap these timers for a pair of light beams inputted through a DAQ chassis. Initially though I wanted to get the content of my program correct, without having to have the equipment connected to my laptop.
    I have attached my progress so far, apologies if my query has an obvious solution. As I say I'm a bit of an beginner! How would I take the two elasped timers log the times found off the timers, compare which one has a greater value and consequently start a new timer depending on this. I would then like to log this time in data form.
    I've tried to compare the two elasped timers with greater than booleans etc but I cant seem to get it to work?
    As I say I hope to use this idea in a time gate sort of application where depending on which light beam is broken first depends on which timer is started. Hope my explanation is clear.
    Any help is much appreciated,
    Thanks very much!
    Attachments:
    FYP.vi ‏15 KB

    PT-
    Looking at your code you have a few problems that you will need to address.  Read the LabVIEW help section titled "Caveats and Recommendations when Using Events in LabVIEW."  You have some latching booleans controls that are incorrectly placed.  The terminals should be in the event case that handles the value change event.  
    Why two event structures?  One structure is a better Idea you can handle all your events with 1 loop (and avoid stopping the loops independantly- this can lead to a condition where the vi becomes unresponsive.
    The lower loop compares the start times to two different timestamps.  This is introducing potential errors since there is timing relationship between the calls to the system timer.  and the lower case structures are rather insane- in english they resolve to "if started return how long its been since started else return 0"  Check the NI website there is a CLD practice exam solution (Car Wash) that has a pretty good example and discussion of using the elapsed timer express vi.  It might point you in a better direction than where you are going.
    Why not use the time terminals in the event structure?  thats the time the event fired.  But, you might want the time the event was handled I don't Know-  (hint-comment your code and write SOMETHING in the vi documentation.  Eventually you'll be writing more complex code so start developing good habits now)  (good habits--)  
    Come on back when you've looked at some of the examples and I'ld be glad to help you more.  
    Jeff

Maybe you are looking for

  • How to solve error in table control?

    Hi expert, I am a beginer in table control. I have a problem. I create a table control in that I use a search help for a column. Everything is normal if I enter a value into search help value and save . There are two situation: 1. In the first time I

  • IPhone 4 Wi-Fi connects, doesn't load anything

    Hello there, Up until a week or two ago my Wi-Fi was working almost flawlessly on all my iDevices. Now however, both my iPad 2 and iPhone 4S have issues loading anything through my home Wi-Fi network. They both identify the network, and about 80% of

  • IPad 3 not charging in greece

    I have all the right connectors and I'm get the Not Charging message when I plug it in to charge. it worked at the Amsterdam airport, but now in Greece it doesn't. Using the exact same connection in Greece, my wife's iPad 2 does charge correctly. Doe

  • Unable to create the Mailbox Store. The database returned an error

    hi we have a new unity connection 10.51 install . trying to create a 2nd mailbax store and get the following error: Unable to create the Mailbox Store. The database returned an error. creates the store but i can't open it to mount it / enable it.

  • Rotating and Translating Objects with Collision Modifiers

    Hello Im trying to build a simple 3d scene. The idea being that a footballer walks up to a football and on detection of that collision, the football is translated or 'kicked.' Got the Collision Detection working using Collision Modifiers. Got it work