Concatenate comparing two rows

Hi all

I have 2 columns in my table;

Col1 Col2

A V
A C
B X
C Y
C Z

I want the result form:

Col1 Col2

A V: C
B X
C Y:Z

If the two lines are identical (say A) then values responsive concate in Col2(i.e..) V:C for A)

Thank you

Or 11 GR 2:

SQL> with data as (
 select 'A' A, 'V' B from dual union all
 select 'A', 'C' from dual union all
 select 'B', 'X' from dual union all
 select 'C', 'Y' from dual union all
 select 'C', 'Z' from dual
)
--
--
select a, listagg(b, ':') within group (order by rownum) b from data
group by a
/
A B
- --------------------
A V:C
B X
C Y:Z                 

3 rows selected.

Tags: Database

Similar Questions

  • Compare two rows in the same table

    Hi all

    I need to compare two rows in the same table, I don't know hoe to do it in pl/sql. Please help me on this.

    example:

    price of ro TR
    xya0001 AMA.7 12
    xya0003 ama6 14
    xya0004 AMA.7 16

    in table b is a unique value for each line, I need to compare the price column and see if the first value is less than or greater than the following value and, if there is more to put the corresponding value of br to a variable, and if it is less, put the corresponding value of the br to another variable. I don't know a method to do this, as I'm new to pl/sql. Please help me in this
    for data in(select tr,br,price, lag(price) over ( order by tr) newcol
    from yourtable)
    loop
    if nvl(data.newcol,0) > data.price then
    variable1:=data.br;
    else
    varable2:=data.br;
    end if;
    end loop;
    
  • COMPARING TWO ROWS IN THE SAME TABLE AND DELETE THEM USING DELETION BLOCK

    Hi all
    I have a problem. I have an Employee table

    employee

    Emp_name Emp_id Emp_status Emp_date

    John 1 P 11-27-2010

    Mike 2 26/11/2010 S

    Simon P 3 22 / 11 / 2010

    Dennis C 4 25/11/2010...


    I compare the rows in the table and their employee_status if 'P', should I remove the... Here, I should delete lines 1 and 3 as their Emp_status is 'P '. I only use BULK DELETE... I tried to use the join query internal and deletion, but it does not work... Can someone help me...

    Ooops, it should be:

    and e2.emp_status in ('P', 'C')

    not

    and e2.emp_status in ('P', 'A')

    Here it goes:

    SQL> select  *
      2    from  employees
      3  /
    
    E EMP_NAME      EMP_KEY          X
    - ---------- ---------- ----------
    C John              123          1
    P Mike              123          2
    P Paul              123          6
    C Harry             124          5
    A Gass              125          7
    C Gass              125          7
    
    6 rows selected.
    
    delete  employees e1
      where 2 = (
                 select  count(distinct e2.emp_status)
                      from  employees e2
                      where e2.emp_key = e1.emp_key
                        and e2.emp_status in ('P','C')
                   )
    /
    
    3 rows deleted.
    
    SQL>
    

    SY.

  • Concatenate two rows

    Hello

    I have a requirement where to check a table with a list of values in reference data.

    I get two rows with a column for each output that every time and I need to concatenate the two rows in a field.

    Is there any combination/processor that can be used to do this?

    I tried concatenate / merge and merge data from processors without success.

    Any direction is much appreciated.

    Thank you

    SID

    It is not clear what criteria do you use to determine which records to eat together. The research is not relevant?

    If it's all the records that spent searching you need to eat, it's simple, you can just add a grouping key (for example to add string to a value of 1 attribute), and then group and merge, creating a merged with output value ' delimited list by a "which is used to create the string.

  • BUG? Statement of BRIDGE to compare two tables

    Hello

    I tried to compare two tables different dbs and remembered a post on applications to Connectin Cross
    http://barrymcgillin.blogspot.com/2010/11/cross-connection-queries.html
    BRIDGE temparb AS "EB05 01"
    (SELECT * FROM arb)
    (SELECT * FROM temparb 
    MINUS 
    SELECT * FROM arb
    )
    UNION ALL
    (SELECT * FROM arb
    MINUS
    SELECT * FROM temparb 
    );
    I expect to get the differences between the ARB table in my current schema and the table alias temparb arb in the other db. Yet it seems that in this case only the table in my current schema is read.

    I materialize at the table BRIDGE with
    BRIDGE temparb AS "EB05 01"
    (SELECT * FROM arb)
    and select the value that I know to be only in the remote schema
    SELECT id FROM temparb WHERE id = 2562;
    SELECT id FROM arb WHERE id = 2562;
    Both times I get no results. I even tried to use aliases on the table, same result. Tested in EA3 3.0 and 3.1.

    Has anyone tried this before?

    Concerning
    Marcus

    Hi Marcus,

    Have you tried without the quotes around the name of connection?

    I have a named connection
    system_local
    which I run the following command

    drop table testbridge_remote;
    drop table testdbrige;
    create table testbridge (col1 int);
    insert into testbridge values (1);
    insert into testbridge values (2);
    insert into testbridge values (3);
    commit;

    I have a named connection
    Name of the connection with space
    I performed the following in the

    drop table testdbrige;
    create table testbridge (col1 int);
    insert into testbridge values (4);
    insert into testbridge values (5);
    insert into testbridge values (3);
    commit;

    Then I can execute the following statement in the connection of system_local/worksheet

    BRIDGE testbridge_remote as the name of connection with Space(select * from testbridge)
    + (SELECT * FROM testbridge_remote +)
    LESS
    SELECT * from testbridge
    +)+
    UNION ALL
    + (SELECT * FROM testbridge +)
    LESS
    SELECT * from testbridge_remote
    +);+

    It works well.
    Returns the rows in the remote table not in the local table and lines in the local table, not the remote table.

    Kind regards
    Dermot
    SQL development team.

  • Problem of VORowImpl - compare two lists of LINE]

    Hello world

    I have a huge problem right now, I am trying to compare two list VO with the same values, it's because a he tied to an advancedtable the xml page where the user can change some values and the other is the table values, but DB, the reason is in fact a validation to compare the original values from the DB with the tabla list and update only lines that users made changes in their values, here is my code for the better explain 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;

    To compare collections
    R1: collection of the app
    R2: collection of comics
    AppVORowImpl r1 = rows1 (AppVORowImpl);
    DBVORowImpl r2 = (DBVORowImpl) rows2 [j]; <-here in the second iteration is displayed the following error message:
    "oracle.apps.fnd.framework.OAException: java.lang.ArrayIndexOutOfBoundsException: 1.

    string variables to check if changes in the column
    String columnAPP = r1.getId (m:System.NET.SocketAddress.ToString ());
    String columnBD = r2.getId (m:System.NET.SocketAddress.ToString ());

    "If" that commits the changes
    {if (! columnAPP.Equals (columnBD))}

    SP string variable
    StringBuilder procedureCall = new StringBuilder();
    the call 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 the futher shows an exception error, what can I do to make this method work?
    I'll be waiting for your answers, I really hope you can help me with this one

    Kind regards
    Mentor

    Here's the code to dump for you. Code, you should write in AmImpl and the same controller class call.

    Code AMImpl

     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
                    }
              }
           }
    
    }
    

    Thank you
    -Anil
    http://oracleanil.blogspot.com/

  • How to compare two lines in PL/SQL?

    Hi all

    How to compare two lines in PL/SQL? Is there a method I can use to compare their column by column instead?

    Any comments would be much appreciated.

    PhoenixBai wrote:
    By lines I mean, two rows of the same table!

    Ah, finally, we get a bit more useful information

    and I need to compare the column by column to see if there is a difference between these two rows.

    Like this, you mean?

    SQL> ed
    Wrote file afiedt.buf
    
      1  with data as (select 1 as id, 'A' as dta, 'B' as dta2 from dual union all
      2                select 2, 'A', 'B' from dual union all
      3                select 3, 'B', 'C' from dual)
      4  --
      5      ,chk as (select &id1 as id1, &id2 as id2 from dual)
      6  --
      7  select case when (
      8    select count(*)
      9    from (
     10      select dta, dta2
     11      from data, chk
     12      where id = id1
     13      minus
     14      select dta, dta2
     15      from data, chk
     16      where id = id2
     17      )
     18    ) = 0 then 'No Difference'
     19          else 'Difference'
     20          end as check_result
     21* from dual
    SQL> /
    Enter value for id1: 1
    Enter value for id2: 2
    old   5:     ,chk as (select &id1 as id1, &id2 as id2 from dual)
    new   5:     ,chk as (select 1 as id1, 2 as id2 from dual)
    
    CHECK_RESULT
    -------------
    No Difference
    
    SQL> /
    Enter value for id1: 1
    Enter value for id2: 3
    old   5:     ,chk as (select &id1 as id1, &id2 as id2 from dual)
    new   5:     ,chk as (select 1 as id1, 3 as id2 from dual)
    
    CHECK_RESULT
    -------------
    Difference
    
    SQL>
    

    My only concern is the result of this sql. East - reliable? It can really be used to differentiate the two lines? I mean, the result would be the same, as I do with Java?

    Not sure what you mean by "reliable"? SQL is not some kind of generator of random result (by derogation from the use of the DBMS_RANDOM package). If you ask him if 1 + 1 = 2, then it will always give you the right answer.

  • How can I move App Tabs down, where are the other bookmark toolbars? Or, how can I put my toolbars on two rows bookmarks and forget the App Tabs?

    I have several bookmarks in my toolbar, and my most often used found in a drop down menu, which is annoying. I have tried to click and drag on the menu bar, there was room for more icons, but they didn't budge. Anything under the "toolbar" has been helpful. Help tell me do right click on my toolbar and then click on 'Customize'... which did not come as an option. I would like to really all my favorites toolbar (I have about 10) or real on the toolbar visible, not hidden in a small dropdown tab menu.
    There is a plug-in that allows you to put bookmarks in two rows on your toolbars, but it is not compatible with my version of FF (7.0.1).
    App Tabs are cute, but I don't like them on top where they take place where I have the legs for various open websites (I usually opened several at once). App Tabs are fixed and do not move as site tabs, which is extremely annoying and so why I 1) want to move to the bottom of the toolbar or 2) be able to view all my bookmarks toolbars - which is what I prefer.
    BTW, I have Windows 7.
    Thanks in advance for your help.

    App tabs are special tablets and are always displayed at the left end of the tab bar.

    You can place all the bookmarks that you want to see the toolbar of bookmarks in the bookmarks toolbar folder.

    You can do this in the sidebar or the Manager of bookmarks if you can't do it on the bookmarks toolbar.

    Most visited is a special file (smart) which shows the websites that you have visited and are not necessarily Favorites, so you can not drag on the personal bar unless you first to bookmark the. You can make it open in a tab by clicking on Star on location bar twice and choose the toolbar of bookmarks as destination folder.

  • How to compare two columns in Xl

    I want to compare two columns in the file of Xl. column A contains phrases and column B contains the words

    For example

    Column A                                                                       Column B                                                                           Column C

    I have an Apple and I'll eat every day Apple Apple

    I have a banana and eat weekly banana papaya

    Oranges are rich in nutritions cauliflowers Oranges

    Papaya is good for health                                               Grapes                                                                                 Papaya

    Oranges

    Lichi

    Banana

    I want to check each value of column B in each cell in column A, and if it matches then it should return the corresponding value in the result to me. Column C should Look Like as shown above.

    Can someone point me in the right direction here of what formula to use for this Xl.

    Thank you

    This is a forum for Mac OS X technologies, so here's an Applescript solution:

    1. Copy-paste the script in the Script Editor
    2. Select the cells in columns A and B
    3. Command + c to copy to the Clipboard
    4. Click on the button "run" in the Script Editor
    5. Click once in the top cell in column C where you want the data
    6. Command + v to paste

    Here are the results:

    There is no verification error here. You must select and copy to the Clipboard before the race.

    SG

    the value LstOfLsts to makeListOfLists (the Clipboard as a 'class utf8 ')

    the value theSentences to getCol1Vals (LstOfLsts)

    the value collected in getCol2Vals (LstOfLsts)

    game of theMatches to «»

    Repeat with I in collected items

    If theSentences contains I then ¬

    the value of theMatches to theMatches & i & return

    end Repeat

    Set the Clipboard for theMatches

    to getCol1Vals (LofL)

    game of col1Vals to «»

    Repeat with en LofL points

    the value col1Vals to the col1Vals & "" & i point 1

    end Repeat

    end getCol1Vals

    to getCol2Vals (LofL)

    the value col2Vals to {}

    Repeat with en LofL points

    If i's point 2 is not "" then ¬

    i copy point 2 to the end of col2Vals

    end Repeat

    return col2Vals

    end getCol2Vals

    at makeListOfLists (theTxt)

    value was to theTxt paragraphs

    the value text point of delimiters

    the value theListOfLists to {}

    Repeat with I from 1 to count was

    the value theListOfLists to the theListOfLists & {the was point i text elements}

    end Repeat

    the value point text delimiters to «»

    return theListOfLists

    end makeListOfLists

  • Comparing two digital channels or waveform

    Hello

    How to compare two digital channels or the y-axis of the same lengths waveform channels and find the line that has about the same value in the channels. For example, suppose we have two digital channels X and Y which has about the same value in line 15. I need to write a script to find out in which line the canals coincide.

    Kind regards

    X.Ignatius

    Hi X.Ignatius,

    I subtract channels and use the CHNFIND function to search for string values that are zero or nearly zero.

    Greetings

    Walter

  • How to compare two source codes?

    Hello

    I would like to know if there is a way to compare the codes from different sources (different .vi or different groups of the vi...) in LabView?

    Our 2 production lines are similar, and I would like to know if there are differences in the 2... 2 production lines management programs because we have to make some changes.

    Thanks for your help

    Benedict

    ... Adding to the message of Putnam...

    We compare two available "Screw" and "VI predetermined.

    It will highlight the differences.

    Ben

  • Is it possible to compare two PDFs using labview?

    I was wondering if it was possible to use LabVIEW to compare two PDF files (that contain images as well as text) to another. I know that Bluebeam PDF viewer can do, so I was hoping there was a way to do it with LabVIEW.

    Read each file as a simple string, and then compare the two strings for equality.

    (You can also do a few tests before, for example just to see if the sizes are equal)

  • compare two tests

    Hi all

    Is it possible to compare two tests and see the result in any video format (graph, or something)

    If so, how can I go to it. ?? in the script, which is possible both manually...

    Thank you

    Skin rash

    Hi Rash.patel,

    I modified your script only in some minor points and used a few more orders of the DATABASE API. I hope that answers your question (more or less).

    Greetings

    Walter

  • I want to compare two tables and out a boolean

    This should be simple.  I want to compare two tables (5 items) and return a single Boolean value (T/F), not an array of Boolean.

    Thank you

    Kevin

    Right click on the comparison, the comparison mode, select compare the aggregates.

  • compare two data

    Hi I want to compare two numeric values is entered by the CNC, and b. If a = b then I want to see 'RAM', if a and b, then I want to see 'JADU' in the indicator.in of the façade. I use the version of labView 13. Please suggest Best looks meyssoun Senapati

    supriyasenapati wrote:

    Mr President, my message itself does not clearly displayed. I don't know why it happened. My real message was like that-

    I want to compare two numeric values is entered by the CNC, and b. If a = b then I want to see 'RAM', if a and b, then I want to see 'JADU' in the indicator.in of the façade. I'm using labView version 13.Thanks.

    Probably you have pasted in HTML Mode and other things betweeen <> had stripped.

    To reproduce, in paragraph above was pasted below while the editing window has been implemented in HTML, this is clearly what has happened!

    Mr President, my message itself does not clearly displayed. I don't know why it happened. My real message was like that--I want to compare two numeric values is entered by the CNC, and b. If a = b then I want to see 'RAM', if a and b, then I want to see 'JADU' in the indicator.in of the façade. I'm using labView version 13.Thanks.

Maybe you are looking for