Merge lines.

Hi all

I have the lines as below.

HIERARCHY_CODE AVS_CODE_TYPE AVS_CODE
CAU1000450112008-07-21
CAU1000450122009-07-20
CAU10004501VLAU0

I need to get the lines like.

HIERARCHY_CODE AVS_CODE
CAU1000450VLAU0 | 2008-07-21 | 2009-07-20

Please, help me merge lines.

Thank you all.

with ta as (select 'CAU1000450' hcode,    11    cd_typ,'2008-07-21' avs_cd from dual union all
            select 'CAU1000450',    12,    '2009-07-20'  from dual union all
            select 'CAU1000450',    1,    'VLAU0'  from dual)
select hcode
     , listagg(avs_cd,'|') within group (order by cd_typ) avs_cd
from ta
group by hcode, decode(cd_typ,1,1,2)

In the absence of a clear set of rules, I'll assume that the cd_typ allows you to differentiate between the description and the start and end dates (1 being the description, beginning 11 12 end)

Tags: Database

Similar Questions

  • In 9i XMLAGG use to merge lines

    Hello

    I have some standard SQL that returns:
    Smith Parameter1 Value1
    Smith Parameter2 Value2
    Smith Parameter3 Value3
    Jones Parameter1 Value1
    Jones Parameter2 Value2
    I want the output to be displayed in the form:
    Smith Parameter1 Value1 Parameter2 Value2 Parameter3 Value3
    Jones Parameter1 Value1 Parameter2 Value2
    I've found that XMLAGG and XMLELEMENT functions make the case:
    SELECT e.EMPLOYEE, RTRIM(XMLAGG(XMLELEMENT(my_element, p.P_NAME||' '||v.P_VALUE||' ')).extract('//text()'), ' ')
    FROM my_employees e, my_parameters p, my_parameter_values v
    WHERE v.P_ID = p.P_ID
    AND v.EMP_ID = e.EMP_ID
    GROUP BY e.EMPLOYEE
    The only thing is, the SQL command order initially lines does not appear when they are merged in a single line, so I can get:
    Smith Parameter1 Value1 Parameter3 Value3 Parameter2 Value2
    Jones Parameter2 Value2 Parameter1 Value1
    He returned in the correct order if I run the SQL without the XMLELEMENTS/XMLAGG function, so I guess it's a question of how the XMLAGG function parses the data?

    Is that what I can do to fix this problem or is there another approach (in 9i) that I can use to get the required result?

    Thank you very much

    Bagpuss

    Published by: Bagpuss on July 22, 2010 03:36

    Published by: Bagpuss on July 22, 2010 03:39

    Bagpuss says:
    Is that what I can do to fix this problem or is there another approach (in 9i) that I can use to get the required result?

    The ORDER BY for XMLAGG clause gives you good results?

    SELECT e.EMPLOYEE, RTRIM(XMLAGG(XMLELEMENT(my_element, p.P_NAME||' '||v.P_VALUE||' ') ORDER BY p.P_NAME).extract('//text()'), ' ')
    FROM my_employees e, my_parameters p, my_parameter_values v
    WHERE v.P_ID = p.P_ID
    AND v.EMP_ID = e.EMP_ID
    GROUP BY e.EMPLOYEE
    
  • How to merge lines

    Hello

    I join 2 tables and the query returns a set of results like this:
    NUMBER                   SNCODE                       VALUE
    333                          70                               'abcd'
    333                          69                               'efgh'
    333                          60                               'ijkl'
    256                          90                               'mno'
    256                          86                               'pqrs'
    256                          60                               'tu'
    256                          45                               'vxyz'
    I need a line by number like this:
    NUMBER                            COLUMNA                               COLUMNB                                  COLUMNC
    333                        case sncode=70 then Y                case sncode=69 then Y               case sncode=60 then Y
    256                        case sncode=70 then Y                case sncode=69 then Y               case sncode=60 then Y                        
    I used the 'CASE' statements in a 'SELECT' statement, but my knuckles gives me a result like this:
    NUMBER                            COLUMNA                               COLUMNB                                  COLUMNC
    333                                        Y                                          N                                               N
    333                                        N                                          Y                                               N
    333                                        N                                          N                                               Y                      
    But the correct answer is
    NUMBER                            COLUMNA                               COLUMNB                                  COLUMNC
    333                                        Y                                          Y                                               Y
    As you can see, I need to merge these 3 rows. Is there a simple way to do?

    Thank you...

    Hello
    Try to decode.
    You must merge the lines.
    Try Max, combination of decoding as shown above.

    Kind regards
    Bobin

  • How can I merge lines and shapes to create a final version?

    Hello

    I am trying to create an icon star with lines through it. I used the generator star-shaped tool, and the line segment tool, but the lines are not recognized as part of the star shape. For example, when I try to turn the star, the lines remain in the same place. It's pretty much exactly what I'm trying to do, but I can't train segments in a coherent, editable form.

    http://www.davekoelle.com/geometry/geom-star_th.png

    Any help would be greatly appreciated. Thanks in advance,

    Keywords

    keywordsarekey,

    Unfortunately I still can't seem to individual segments to fill those I would like to

    You should be able to do with paint live, at least if you give the original Star a filling first.

    Or you can check view > commented, then:

    (1) slide with the line tool outer corner at the inner corner opposite to all divisions (Smart Guides say anchor at each end), as many lines as the star's points.

    (2) select lines and demarcation object > path > divide objects below, this creates paths triangular to give different fills, probably with a few trails of trash in the Center, see 4.

    (3) select each of the triangular paths (you can drag onto the external segment) and set the fill color, you can do this in groups for each color so you have just to tisk filling in the Tollbox box;

    (4) if necessary, select each path that appears in the extended layers palette and remove paths from the Recycle Bin appears in the Center.

  • Merge lines with a non-primary key of a row without losing data

    Hello people,


    Do you know how I can get all the entertainment on a single line ID? As you can see there is a line for each kind of pastime for each code.

    ID---FNM--LNAME--HOBBY1---HOBBY2---HOBBY3---HOBBY4
    100 jan - Jansen - race-
    100 - Jan - Jansen dance-
    100 jan - Jansen - works
    101 Dan - Dansen - race-
    101 Dan - Dansen - works
    102 Jeff - Eulalie - race-
    102 Jeff - Eulalie - pool -.

    Result must be present;

    ID---FNM---LNAME---HOBBY1---HOBBY2---HOBBY3---HOBBY4
    100--Jan---Jansen---running---dancing---walking
    101 Dan - Dansen - running - walking
    102 Jeff - Eulalie - running - pool -.


    Thank you!

    Published by: 868316 on June 25, 2011 04:11

    868316 wrote:
    I forgot to mention that I had this table, for example hobby.

    All the answers to your hobby of on-the-fly question use table (WITH clause). Just Remover it. For example, you have table hobby, right? Then adjust my solution:

    select  id,
            fnm,
            lname,
            max(hobby1) hobby1,
            max(hobby2) hobby2,
            max(hobby3) hobby3,
            max(hobby4) hobby4
      from  hobby
      group by id,
               fnm,
               lname
      order by id,
               fnm,
               lname
    / 
    

    SY.

  • simple way to merge two rows in a

    11g 11.2.03
    with test_temp as 
     (select 'x' key,to_char(1) col1,null col2 from dual
      UNION
      select 'x' key,null col1,'a' col2 from dual
      UNION
      select 'y' key,'a' col1,'b' col2 from dual
      UNION
      select 'z' key,'a' col1,null col2 from dual
      UNION
      select 'z' key,null col1,to_char(2) col2 from dual)
    select * from test_temp
    gives
    KEY    COL1      COL2 
    ----- -------  -------  
    x        1
    x                  a
    y        a         b
    z        a       
    z                  2
    smart way to get:
    KEY    COL1      COL2 
    ----- -------  -------  
    x        1        a
    y        a        b
    z        a        2
    Essentially, I want to merge two lines based on a common key and remove all columns with NULL values, and merge them into a single line. The col1 and col2 can have any data types (number, char, date, etc.) ideas?

    Published by: user13007502 on July 13, 2012 01:11

    Published by: user13007502 on July 13, 2012 01:46

    Published by: user13007502 on July 13, 2012 02:05

    Published by: user13007502 on July 13, 2012 02:09

    user13007502 wrote:
    Sorry guys. My example was not the best. The numbers are just one example. I expanded the sample to display more realistic data.

    I just want to know if there is a smart way to merge two or more lines according to a key. Line is merged only when the merged line will result in a single line.

    So, as I said...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with test_temp as
      2   (select 'x' key,to_char(1) col1,null col2 from dual
      3    UNION
      4    select 'x' key,null col1,'a' col2 from dual
      5    UNION
      6    select 'y' key,'a' col1,'b' col2 from dual
      7    UNION
      8    select 'z' key,'a' col1,null col2 from dual
      9    UNION
     10    select 'z' key,null col1,to_char(2) col2 from dual)
     11  select key
     12        ,max(col1) as col1
     13        ,max(col2) as col2
     14  from test_temp
     15* group by key
    SQL> /
    
    K C C
    - - -
    z a 2
    x 1 a
    y a b
    

    What is the problem you are having?

    I feel that you don't even try the solutions proposed. Or well you're not giving us a pretty good example of what is the question.

  • insert/update County in the merge statement

    In the Merge statement, we can count the number of inserted rows and updated?

    ROWCOUNT SQL % simply returns the number of rows merged.

    It does not tell us the separately the line inserted and updated.

    # To insert the rowcount is the number of inserted rows for update is the number of rows updated, for the merger, that's the number of merged lines.

  • Select data to Analytics statement grouping

    Select * from version of v$.

    Database Oracle 12 c Enterprise Edition Release 12.1.0.2.0 - 64 bit Production

    PL/SQL Release 12.1.0.2.0 - Production

    CORE Production 12.1.0.2.0

    AMT for Linux: Version 12.1.0.2.0 - Production

    NLSRTL Version 12.1.0.2.0 - Production

    DROP TABLE t1;

    CREATE TABLE t1

    (

    domain VARCHAR2 (20).

    gasday DATE,

    factor_type VARCHAR2 (20).

    factor_value INTEGER

    );

    INSERT INTO t1

    VALUES (field 'A',

    SYSDATE,

    ' FACTOR_TYPE 1',

    (1);

    INSERT INTO t1

    VALUES (field 'A',

    SYSDATE + 2,

    ' FACTOR_TYPE 1',

    (1);

    INSERT INTO t1

    VALUES (field 'A',

    SYSDATE + 4,

    ' FACTOR_TYPE 1',

    (3);

    INSERT INTO t1

    VALUES ('field of B',

    SYSDATE,

    ' FACTOR_TYPE 2',

    (1);

    INSERT INTO t1

    VALUES ('field of B',

    SYSDATE + 2,

    ' FACTOR_TYPE 1',

    (2);

    INSERT INTO t1

    VALUES ('field of B',

    SYSDATE + 4,

    ' FACTOR_TYPE 2',

    (1);

    SELECT * FROM t1;

    SELECT the field,

    factor_type,

    factor_value,

    gasday,

    (Gasday, 1) ahead OF (PARTITION BY factor_type ORDER BY gasday field) - 1 valid_to

    FROM t1;

    FIELDFACTOR_TYPEFACTOR_VALUEGASDAYVALID_TO
    To fieldFACTOR_TYPE 1114.05.201515.05.2015
    To fieldFACTOR_TYPE 1116.05.201517.05.2015
    To fieldFACTOR_TYPE 1318.05.2015
    Field BFACTOR_TYPE 1216.05.2015
    Field BFACTOR_TYPE 2114.05.201517.05.2015
    Field BFACTOR_TYPE 2118.05.2015

    Issues related to the:

    I would like a group/merge the first two rows will be grouped as follows:

    FIELDFACTOR_TYPEFACTOR_VALUEGASDAYVALID_TO
    To fieldFACTOR_TYPE 1114.05.201517.05.2015

    I wish I had the last two lines in the result above to be "concatinated" / merged, as follows:

    FIELDFACTOR_TYPEFACTOR_VALUEGASDAYVALID_TO
    Field BFACTOR_TYPE 2114.05.2015

    Therefore, my final result of my query should resemble the following:

    FIELDFACTOR_TYPEFACTOR_VALUEGASDAYVALID_TO
    To fieldFACTOR_TYPE 1114.05.201517.05.2015
    To fieldFACTOR_TYPE 1318.05.2015
    Field BFACTOR_TYPE 1216.05.2015
    Field BFACTOR_TYPE 2114.05.2015

    How do I get there?

    The rule is:

    If the domain group, factor_type, and factor_value values and last place in the Group has an open end (IE valid_to is NULL), then the merged line should also have an open end. Or, if the last row has a value for VALID_TO, this value should be used for VALUE_TO in the line of fusion / grouped.

    I wrapped your SQL in an aggregate like this query:

    Select field, factor_type, factor_value, min (gasday), max (valid_to) keep (dense_rank last nulls valid_to service modified)

    de)

    SELECT the field,

    factor_type,

    factor_value,

    gasday,

    (Gasday, 1) ahead OF (PARTITION BY factor_type ORDER BY gasday field) - 1 valid_to

    FROM t1

    )

    Domain group, factor_type, factor_value

    order by 1,2,3;

    It seeks to achieve what you want, even if I'm not following the logic behind your needs

  • Create 2 HeaderRow or similar

    Hello guys,.

    To begin with, sorry if the title is not the best description of my problem.

    As you know livecycle Designer limit a little work with tables, in other words, not being able to merge lines.

    As you can see in the picture next, marked with a circle of my solution is to configure all free space below where I want the aditional titles in the header row and push the texts of two field with borders United instead. My problem now is... I want the place to be on the next page if I increase my table enough (line header in the following pages)... How can I copy these 2 titles("Original/Atual") as well as the header row. I hope I made myself understood and I'll have your precious help guys! Fire away!

    problem.png

    Kind regards

    David.

    Hello

    Thanks for the reply Magus. My problem still happen using the "include header row in the following pages", because those 2 boxes saying "Original and Atual" are actually 2 text placed there and not the cells in the header row, so they appear in the following page.

    Because you cannot merge line on livecycle, it's the solution I found to get the layout I wanted to...

    But I just discovered another way and I'll leave it here incase someone has something similar to happen...

    It works with the option "include the line header in the following pages. Basically, I this cell object became a subform West flowed and put 3 text boxes with dimensions of corret inside get the same presentation and making it all part of the HeaderRow so solve my problem.

    Thanks anyway guys.

  • Is it possible to add text to the cells and apply the character style in the cell

    I work in InDesign on Mac 5.

    I have two tables of formatting with information that will be eventually combined. I implemented the scripts I found on these forums to add the columns needed, merge lines and fill the cells merged with the appropriate color, but can't two remaining tasks.

    1. is it possible to add text to a cell of some?

    2 and it is possible to apply a character style to cells? (different cells than those that I need to add some text)

    I played with this code but do not know if it is even close...

    {

    table. Rows [0]. Cells [0]. InsertText (' CS/PS");

    }

    {

    table. Rows [0]. Cells [0] .appliedCharacterStyle ("bold");

    }

    Here are the scripts that I have combined so far for the table...

    Add column

    myTable = app.selection [0];

    MyColumn = myTable.columns [1];

    for (a = 0; < 1; a ++)

    {

    myTable.columns.add (LocationOptions.AFTER, myColumn);

    }

    Merge lines

    table = app.selection [0];

    If (table.hasOwnProperty ("baseline") table) = table.parent;

    If (instanceof cell table) table = table.parent;

    If (instanceof column table) table = table.parent;

    If (instanceof row table) table = table.parent;

    If (instanceof Table table)

    {

    table. Rows [0]. Cells [0]. Merge (table.rows [0] .cells [1]);

    }

    {

    colours alternating in merged lines

    r = table.rows [1];

    n = app.activeDocument.swatches.item ("orange");

    b = app.activeDocument.swatches.item ("PANTONE 3005 C");

    for (c = 0; c < r.cells.length; c ++)

    {

    If (c & 1)

    r.Cells [c]. Properties = {fillColor:b};

    on the other

    r.Cells [c]. FillColor = n;

    }

    }

    Hello

    1. If you want to add the text, go further in:

    table. Rows [0]. Cells [0] .insertionPoints [0] .silence = ' CS/PS;

    2 similar with application of styles:

    table. Rows [0]. Cells [0] .texts [0] .appliedCharacterStyle = "bold" / / If this style is present in your doc

    Jarek

  • Semi-automatic conflict resolution of building

    Hi all

    Interesting challenge: when a conflict occurs, my client does not want to bother the operator with the resolution of the conflict. In most cases, my client wants the conflict to be resolved automatically (which, in the simplest cases is not so difficult - someone has an attribute on a record that doesn't affect your work, but creates a conflict when merging your workspace), unless the conflict is too difficult: so a message should simply say : impossible right now.

    Here's the workflow I have in mind:

    User A creates a workspace wA
    B the user creates a workspace wB
    User B C 1234 in wB file attribute changes
    B the user undertakes
    User attribute changes D folder 1234 to wA
    The user agrees, gets a conflict
    Software checks the changes
    considers that this change will not come into conflict
    'charging' original recording 1234
    changes the D attribute
    Commits again

    Is this feasible? I would like to think, but don't have time for a real test in the code.

    Thank you
    Stefan

    Hello Stefan,

    Yes, it would be feasible for all the columns that can be compared for equality. He should be able to compare for equality to know which columns have been modified since conflicts are marked at the level of the line. Then, it would be easy to make the necessary updates on the merged lines.

    OWM is not that there are cases where using these two changes would be incorrect because of the business logic, etc. Thus, we leave the application to decide whether to implement such a feature.

    Kind regards
    Ben

  • currval, nextval vs

    Hello

    Can someone explain to me the following behavior:

    Select
    OBJECT_ID,
    MOD(OBJECT_ID,2),
    CASE WHEN MOD (OBJECT_ID, 2) = 1 then seq_general.nextval to another seq_general.currval END
    from user_OBJECTS;

    Returns something like:

    OBJ_ID, MOD, SEQ
    1,1,1
    2,0,2
    3,1,3
    4,0,4

    When instead I was aiming for:

    1,1,1
    2,0,1
    3,1,2
    4,0,2

    Thank you

    Hello

    The explanation is simple, see [how to use sequence values | http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/sql_elements6a.htm#80564]:

    In a statement Oracle SQL single containing a reference to the NEXTVAL, increments the sequence only once:

    For each returned row by the outer query of a select block. This type of query block can appear in the following locations:
    SELECT Top Level o a statement
    o an INSERT... SELECT statement (single table or multiple tables). For a multi-table insert, NEXTVAL reference must appear in the VALUES clause, and the sequence is updated once for each row returned by the subquery, although NEXTVAL can be referenced in several branches of the multi-table insert.
    o A CREATE TABLE... LIKE the SELECT statement
    o A CREATE MATERIALIZED VIEW... LIKE the SELECT statement
    For each line put updated in an UPDATE statement
    For each instruction INSERT containing a VALUES clause
    For the "merged" line (inserted or updated) in a MERGE statement. The reference to NEXTVAL may appear in the merge_insert_clause or the merge_update_clause.

    If one of these locations contains several references to NEXTVAL, then Oracle increments the sequence once and returns the same value for all instances of NEXTVAL.

    If one of these locations contains references to both CURRVAL and NEXTVAL, then Oracle increments the sequence and returns the same value for CURRVAL and NEXTVAL.

    See also a very good explanation in [why is out of the seqname.currval, seqname.nextval, seqname.currval, seqname.nextval selection of double like this? | http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:21115948632804]

    Kind regards

    Published by: Walter Fernández on July 7, 2009 19:45

  • Comma in the subject line after the merger of field

    I'm trying to create a fusion of our contact, followed a first name field comma and space, then the subject line.

    The kicker is, I don't want the comma (and space) will appear if we do not have a name associated with the e-mail address...  How can I do this?

    Here's what I have so far...

    < eloqua type = "emailfield" syntax = "FirstName" > name < / eloqua > line object here...

    I would like the result of the following:

    w/name:  Rob, line topic here...

    no name: Line of subject here...

    I tried to insert a comma and a space in various locations in the merge field code with no luck.

    Any help is appreciated.

    See you soon

    Hi, Rob. Nice name. Recently, I asked a similar question in this thread. Maybe some useful information for you.

  • Can I add merge field to contact the subject line?

    I am trying to find a way to add a merge field to contact the subject line

    Open the merge field dialog box, and then drag the fusion in the subject line. Once it is there, you can't move it really, but you can change the text around it. Another option is to paste the code in your subject line. Then save and exit the email. When you open new, you will see the familiar yellow fusion indicator.

  • Merge a pdf form to be completed on-line with a scanned pdf document

    Is it possible to merge a pdf form to be completed on-line with a scanned pdf document? Our society needs a way to combine a pdf form to be completed on-line with a scanned pdf document to send as an attachment a.

    Of course, assuming that they are not secure, digitally signed or created using LiveCycle Designer.

    You can do this via file - create - combine multiple files into a single PDF file.

Maybe you are looking for

  • lost any opening

    Hello Downloaded El Capistan now Aperture and all my photos are lost, because it does not support my version. How can I recover my photos?

  • Satellite A305 - strange problem with power LED

    I have the Toshiba Satellite A305-S6825 and I noticed that when I run the laptop on electric power, the battery light (LED) on the front of the laptop is "illuminated". AC power ligtht is the first light on the left; and law who is the witness bright

  • Pavilion a409.uk fails to copy files during the installation of XP.

    Hello I have a Pavilion a409.uk, which is a failure during the installation of Windows XP Professional SP2 I get a file copy error "Setup cannot copy the file sqls20.dll. This is a clean install, deleting the previous partitions and create a new inst

  • ICONIA W 510 forgotten password

    Hello I forgot the password of Windows 8 of my 510 W ICONIA. I tried several times and I couldn't get it back. So I decided to format and reinstall Windows 8. I loaded 8 win in my USB as a bootable, I changed the boot menu to first load the USB HDD.

  • OCR problem

    OfficeJet Pro 8600 more supposed to have integrated OCR capability.  When I scan it provides PDF format as save option.  What should I do to get this in an editable format and MS Word?