merge multiple lines in a row (but multiple columns)

How to merge multiple lines in a row (but several columns) effectively.

For example

IDVal IDDesc Id_Information_Type Attribute_2 Attribute_3 Attribute_4 Attribute_5 Attribute_1 IdNum
23 asdc 1 location USA NM ABQ four seasons 87106
23 asdc 1 Stats 2300 91.7 8.2 85432
23 asdc 1 Audit 1996 June 17 1200
AAFC 65 2 location USA TX AUS Hilton 92305
65 AAC 2 Stats 5510 42.7 46 9999
AAFC 65 2 Audit 1996 July 172 1100


where different attributes mean different for each Information_type.
For example, for Information_Type = location
Attribute_1: countries
Attribute_2: State and so on.


For example, for Information_Type = Stats
Attribute_1 designates the Population
Attribute_2: percentage of ethnicity American and so on.

I want to create a view that shows as below:

IDVal IDDesc IDNum country state city hotel ZipCode American Population % other % area Audit year Audit AuditMonth Type AuditTime
23 asdc 1 USA NM ABQ reviews 87106 2300 91.7 46 85432 1996 June 17 1200
AAFC 65 2 USA TX AUS Hilton 92305 5510 42.7 46 9999 1996 July 172 1100


Thank you

Hello

This is called pivoting . The FAQ forum has a section on this subject: {message identifier: = 9360005}

I hope that answers your question.
If not, post your best attempt, as well as some examples of data (CREATE TABLE and INSERT, only relevant columns instructions) and also publish outcomes from these data. (See you the desired results, but they are very difficult to read because they are not formatted. Use \.

 tags, as described in the forum FAQ, below.)
Explain, using specific examples, how you get the results you want from the data given.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).  This is always important, but especially so with pivots.
See the forum FAQ {message:id=9360002}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

Tags: Database

Similar Questions

  • Merge multiple columns into a single column?

    Hello

    I need to perform queries dynamically and the return values. I need to retrieve the values of the queries in a single column only by concatenating multiple columns. I can't use the PL/SQL in my scenario.
    is it possible to run a query and the result will be extracted in a single column (multiple column values must be concatenated)?

    Thank you
    Raja.
    SELECT rtrim(extract(xmltype(REPLACE(column_value,'
    

    Check this box... Copy it directly to this

    Ravi Kumar

  • Several lines in a row with different column name

    Hello
    I have the table "v_Profile_ID" and "v_Trasaction".

    V_profile_ID columns
    1 profile_nbr
    2 idendifaction_number

    V_Trasaction columns (a historical data)
    1 profile_nbr
    2 Transaction_ID
    3.TransactionDate_Time
    4.Transaction_amount


    common profile_nbr in the tables 'v_Profile_ID' and 'v_Trasaction '.

    Are values in the v_profile_ID table

    profile_nbr Identification_nbr

    1001 Au1002
    1001 BD9089
    1001 FC3900


    To view the identification_3 of v_profile_ID, identification_2, identification_1, Profile_nbr
    and TransactionDate_Time Transaction_amount of v_Trasaction

    Profile_nbr identification_1 identification_2 identification_3 TransactionDate_Time Transaction_amount

    1001 Au1002 BD9089 FC3900 1000 2 April 2011


    Please can someone help me

    Thank you
    Petrilla

    Hello

    Try this... !!

    Select profile_nbr,
    max(decode(seq,1,identification_nbr,null)) identification_1,
    max(decode(seq,2,identification_nbr,null)) identification_2,
    max(decode(seq,3,identification_nbrl,null)) identification_3
    
    from (select profile_nbr,identification_nbr,row_number()
        over(partition by profile_nbr
           order by identification_nbr) seq
            from table_name) where seq<=3;
             group by profile_nbr;
    

    Concerning
    KPR

    * If it's OK... then do as correct
    * If it's useful... then make it as useful

    Published by: KPR on April 29, 2011 04:53

  • How to convert multiple lines in 1 row of columns across

    Hello

    My DB 10g

    My data as below,
    84A8E46E9366     20111008133638
    84A8E46E9366     20111112000531
    84A8E46E9366     20111212004432
    84A8E46E9366     20120127173533
    84A8E46E9366     20120226235444
    I've already tilt it by
    select 
    msid,
    rtrim (xmlagg (xmlelement (e, fee || '|')).extract ('//text()'), '|') fee
    from 
    aaa_bill
    where msid='84A8E46E9366'
    and fee is not null
    group by 
    msid;
    and get the result as below with only 2 column
    84A8E46E9366     20111008133638|20111112000531|20111212004432|20120226235444|20120127173533
    but I need the result to be on multiple columns.
    so I tried the following
    select msid,REGEXP_SUBSTR ( fee
               , '^[^|]*'
               )
    from 
    (
    select 
    msid,
    rtrim (xmlagg (xmlelement (e, fee || '|')).extract ('//text()'), '|') fee
    from 
    aaa_bill
    where msid='84A8E46E9366'
    and fee is not null
    group by 
    msid
    )
    ;
    but the result, only the first string

    84A8E46E9366 20111008133638


    is it possible to get Thos on several columns each string on column separated automatically because I have about 20000 msid separate

    Hello

    See the FAQ forum: {message identifier: = 9360005}

    In Oracle 10, you can do this:

    WITH     got_c_num     AS
    (
         SELECT     msid
         ,     fee
         ,     ROW_NUMBER () OVER ( PARTITION BY  msid
                                   ORDER BY          fee     -- or whatever
                           ) AS r_num
         FROM     aaa_bill
         WHERE     ...
    )
    SELECT       msid
    ,       MIN (CASE WHEN c_num = 1 THEN fee END)     AS col_1
    ,       MIN (CASE WHEN c_num = 2 THEN fee END)     AS col_2
    ,       MIN (CASE WHEN c_num = 3 THEN fee END)     AS col_3
    ...
    ,       MIN (CASE WHEN c_num = n THEN fee END)     AS col_n
    FROM       got_c_num
    GROUP BY  msid
    ORDER BY  msid     -- If wanted
    ;
    

    Note that you must specify the number of columns in the output. If you are unsure, do a high hypothesis. The query works always; unused columns will be NULL.

    Published by: Frank Kulash on 12 March 2012 14:45

  • Swivel... Several lines in simple row, multiple column

    Dear Oracle Guru

    I have a table
    emp_req_order
    the fields are
    EmpNo, Deptno, req_order

    I need to find the max of Req_order for all dept

    so my request was

    SELECT max (req_order) emp_req_order Maxorder
    Deptno group

    put it was

    MaxOrder
    -----------
    45
    34
    23
    17

    I want the output of a line like

    45 34 23 17

    Instead of four rows data must be in a line, but four columns

    I searched the forum I even had a proposal as follows:
    Max (SELECT Decode(deptno,101,req_order)) const1,
    Const2 Max (decode(DEPTNO,102,req_order)),
    Const3 Max (decode(DEPTNO,103,req_order)),
    Const4 Max (decode(DEPTNO,104,req_order)),
    Of emp_req_order
    Group By deptno


    The output was still in several lines

    Kindly guide me in this regard

    with the best regards

    RSS

    SSR,

    Just drag the group clause for the purpose.

    Kind regards
    Rob.

  • IDCS6 MACOSX JS: data merge multiple txt files one after the other

    Hello everyone.

    I have a situation where I have to data merge multiple text files to a single file indesign real "base". Databases formats are the same, the point of difference is a code in the second field of the database that refers to a postal box (not a zip/postal code, a code of 'distribution center' that has possibilities of 56 or greater). I would prefer data merge a file and then somehow split the PDF via Acrobat, but the length of postal areas resulting is incompatible and something that cannot be done if the document "split" feature in acrobat.

    The database starts as one massive file but using a one line code, can be divided into postal areas in separate text files.

    My last question: is it possible data merge several files at the same time (for example one after the other) and to give them their names based on the names of the input text file?

    OLE Kvern had a script to merge the data to a file without the user interface. I changed the last line slightly so that it generates a PDF file based on [high quality]:

    if(app.documents.length != 0){
            var myDocument = app.activeDocument;
            app.dataMergeOptions.removeBlankLines = true;
            //Select a source file.
            var myDataFile = File.openDialog("Select a data file")
            var exported = "file location(redacted for the sake of this post)"
            if(myDataFile != ""){
                    myDocument.dataMergeProperties.selectDataSource(myDataFile,);
                    myDocument.dataMergeProperties.exportFile(exported,"[High Quality Print]",);
            }
    
    }
    

    I guess that the answer has to do with the variable "myDataFile" and rather than just being open a dialog box, it could be somehow by selecting a table of text files, but it is where I am out of my depth.

    Ideas or thoughts which may not involve trying to do both the many mergers, but can somehow revolve around a great fusion of PDF?

    Thank you very much

    Colin

    Since writing my last response, I realized there was a better answer. It is a scenario of Peter Kahrel and a modified version of a script by Olav Kvern. Details can be found here: batch of merge data | Adobe Community

    I have since made other mods to the script is easier to understand:

    if(app.documents.length != 0){
    // make sure to use the document that is open
            var myDoc = app.activeDocument;
    // get the name of the document that is open for future naming purposes
            var myName = myDoc.name
    // get the location of the folder that contains both the indesign files and the text files
            var myLocation = "FULL PATH LOCATION OF FOLDER CONTAINING TEXT FILE AND DESTINATION FOR FINAL PDFS"
    // define the names of the data files to use based upon the names of the indesign files
            var myImport = myLocation + myName + ".txt"
    // define the names of the data merged PDFs to be created
            var myExport = myLocation + myName + ".pdf"
    // the actual engine for the merge, including DM instructions such as remove blank lines, object fitting etc.
            var myDataFile = myImport
            app.dataMergeOptions.removeBlankLines = true;
            if(myDataFile != ""){
                    myDoc.dataMergeProperties.selectDataSource(myDataFile,);
                    myDoc.dataMergeProperties.exportFile(myExport, "[PDF/X-1a:2001]", );
            }
    
    }
    

    If this script will automatically merge a file which is open as LONG as the data file is the same name as the indesign file with .txt at the end for example

    Woodward.indd (indesign file)

    Woodward.indd.txt (used for merging text file)

    This script does still not the original memory and who was using an indesign document, to browse for many text files and merging of PDF based on text files.

    HOWEVER, I am sure that the answer to that is based only on the use of the script above (no need to Peter batch convert script) and changing the line 9 to be a loop for... but again, this is where I come to a grinding halt. Any help would be appreciated.

    Colin

  • How to merge multiple images into a single document and place them on the bottom

    I am trying to merge multiple images in a single document and arrange them on this document and save it.  Is it still possible?  There are five black and white drawings that I've resized at all have the same size.  Tutorials that I looked at, but it seems that everyone has another way to do this and all are very confusing.  Thanks for your help.

    It is not surprising that "everyone has a different way to do this." In Photoshop that is common. Try this:

    1. open a new file large enough to accommodate five drawings.

    2. open each design, click on it in the layers panel and drag and drop it in the layers panel to the new file.

    3. Repeat until all are in the new file

    4. use the move tool to reposition. (They are on separate layers)

    5 flatten the file if you wish (but save a version not flattened for future editing)

  • How can I create sequential shooting (1 for each 'row') numbers in a script in multiple column?

    How can I create sequential shooting (1 for each 'row') numbers in a script in multiple column?

    Sorry, but for now there no such function to put sequential numbers in the column number drawn.

  • You can merge multiple Webhelp projects?

    Hi all

    Is it possible to merge multiple Webhelp projects separately created so that when you start a project, you can see the table of contents of other projects as well? (that is to say, they would all appear to be part of the same assistance but were actually created separately). I use RH10.

    Thank you.

    See merged help on my site.

  • Merge multiple images into a single file

    Hi all

    I am writing because I need to merge multiple images into a single file and do not know how.

    I need to create a large table with several aerial photographs, so I didn't need to create a panorama, but I would like to use an automatic procedure to merge the images because they are many.

    Can you help me??

    I tried photomerge but it creates more levels without ordering the photos...

    If all the files are the same size, there is a script "File Stitcher" @ http://www.ps-bridge-scripts.talktalk.net/

  • __Is - it a way to "merge" multiple curves in a single curve?

    __Is - it a way to "merge" multiple curves in a single curve?

    By that I mean I have file with layers of curve 2-12 - I wanted to "merge" the curves so that I can end up with a single curve with the attributes of a lot. Maybe there at - it a script that would do this?

    I don't want to not be critical, but how get you to a situation where you have 12 layers of curves?

    The advantage of a curves layer is that you can adjust and re - adjust to your heart's content.

    If you usually add new curved layers one over the other, maybe you should re - evaluate your work process.  Maybe bit depth the way you think you should operate at a high level and make the operations of curves on the pixels?  Or put some time in retraining yourself do not add a new layer of curves but to manipulate that is already there.  There are some nice new improvements (e.g., subtool 'finger' that allows you to choose a location for the image and manipulate this part of the curve).

    Once again, I don't mean to criticize you, just look to see if maybe there's a way to avoid getting to the point where you need to combine the curves in the first place, since there is no direct possibility of "Merge curves", apart from the stamping a whole layer image and adjustment in pixels.  To be complete, I guess I should mention how...  Any combination of visible layers into a single layer of pixels (effectively combining all the curves layer and al.), you can stamp by pressing Ctrl - Shift - Alt-E.

    -Christmas

  • Data merge multiple records do not work

    Hi all

    When you try to merge multiple records, the result is the same if I selected just a recording.

    Here's the situation:

    Source file:

    • Excel file with several records, saved as a csv and txt

    The target file:

    • InDesign CS4 file with a single page.
    • framework of a text on the page,
    • a table with the header line and a line of body
    • every cell of body line contains a data field

    I went through all the necessary steps:

    • Choose the data source file (tried with csv and txt, the results are the same) and insert the fields in the table
    • chose "All records" to merge
    • to merge records: selected multiple records

    After choosing "Preview", I see only one record per page, and the new pages are created automatically for EACH record! This is not what I want.

    What I want is for as many records if poster in the table as possible and then to InDesign to create additional if necessary pages.

    What I am doing wrong, or isn't it possible?

    Thank you for all your comments!

    Several records, ID to duplicate everything on the page, so unless there is enough space for all of this, you will get several records.

    Think of it as a frame around all your items, group, then using the step and repeat, except merge data won't allow any element to extend beyond the edge of the drawing page.

  • Merge multiple PDF in c# using Acrobat 7.0 files

    I'm trying to merge multiple PDFs into a single pdf file. Does anyone have sample or pseudo code for this?

    Basically, it has hardly changed since version 5 you can use also. 8 SDK / section IAC.

    The command to use is "insert", where the first page must be opened and the other pages will be inserted.

    If you use google for PdDoc.insert you can get tons of examples and perhaps also in C.

    If you use the Acro-Javascript via IAC you can find an example directly in the help file AcroJs.

    HTH, Reinhard

  • Mergeing multiple procedures in one package?

    Hello gurus,


    I m moving data from a diagram i, e la source (SRC) schema to the schema an another i, e target (trg) table, only selected columns of a few tables (i, e for 4 tables)


    I m, writing procedures to achieve and maintain this procedure a planner on a daily basis to load



    I m 4 procedures of writing for each of the table... is the procedure that I got
     
    
       create or replace procedure mov_tbl1
       is 
        cursor tbl1_cur as
          select  src.col1,
                     src.col2,
                     src.col3,
                     src.col4
             from source.tbl1 src
              where col1 = ' xyz'
           
        tbl1_cur_rec   tbl1_cur%rowtype;
            
          begin 
                for  tbl1_cur_rec  in tbl1_cur
                loop 
                    insert into tgt.tabl1(col1,col2,col3,col4)
                          values (   tbl1_cur_rec.col1,
                   tbl1_cur_reccol2,
                   tbl1_cur_rec.col3,
                   tbl1_cur_rec.col4);
                         commit
                      exception 
                         when others then 
                            rollback;
                  end loop;
          end;
    
       ---for table 2
    create or replace procedure mov_tbl2
       is 
        cursor tbl2_cur as
          select  src.col1,
                     src.col2,
                     src.col3,
                     src.col4
             from source.tbl2 src
              where col3 = ' abc'
           
        tbl2_cur_rec   tbl2_cur%rowtype;
            
          begin 
                for  tbl2_cur_rec  in tbl2_cur
                loop 
                    insert into tgt.table2(col1,col2,col3,col4)
                          values (   tbl2_cur_rec.col1,
                   tbl2_cur_reccol2,
                   tbl2_cur_rec.col3,
                   tbl2_cur_rec.col4);
                         commit
                      exception 
                         when others then 
                            rollback;
                  end loop;
          end;
    
       
    same procedures for table 3 and table 4...

    Here's my question...
      
    
    1.How can i build a single package for all these four procedures in one package ???
    2. ANd i don't want to call each procedure every time ...so can i do it by passing parameters ???  how can i accomplish that ??
    
     
    I m back to writing packets... all help is greatly appreciated... Thank you so much gurus!

    First your code does not compile because the exception block is inside the loop while begin and end are on the outside.
    You must decide whether a row error should invalidate the full load or if the wrong single line must be rejected, but all other lines have been downloaded.
    I guess you need that last so I change the code as follows:

    create or replace procedure mov_tbl1
       is
        cursor tbl1_cur as
          select  src.col1,
                     src.col2,
                     src.col3,
                     src.col4
             from source.tbl1 src
              where col1 = ' xyz'
           -- the record variable declaration is implicit in FOR LOOP
          begin
                for  tbl1_cur_rec  in tbl1_cur
                loop
                  begin
                    insert into tgt.tabl1(col1,col2,col3,col4)
                          values (   tbl1_cur_rec.col1,
                   tbl1_cur_reccol2,
                   tbl1_cur_rec.col3,
                   tbl1_cur_rec.col4);
                         -- REMOVED COMMIT, Commit outside or at the end.
                      exception
                         when others then
                           null; -- May be is better to (somehow) log the error ...
                  end;
                end loop;
          end;
    

    On the package, create you it in this way:

    create or replace package p is
    procedure upd (tab1 in boolean, tab2 in boolean, tab3 in boolean, tab4 in boolean);
    end;
    /
    
    create or replace package p is
    procedure upd (tab1 in boolean, tab2 in boolean, tab3 in boolean, tab4 in boolean) is
    begin
      if tab1=true then
         mov_tbl1;
      end if;
    
      if tab2=true then
         mov_tbl2;
      end if;
    
      if tab2=true then
         mov_tbl2;
      end if;
    
      if tab2=true then
         mov_tbl2;
      end if;
    end;
    
    procedure mov_tbl1   is
        cursor tbl1_cur as
          select  src.col1,
                     src.col2,
                     src.col3,
                     src.col4
             from source.tbl1 src
              where col1 = ' xyz'
           -- the record variable declaration is implicit in FOR LOOP
          begin
                for  tbl1_cur_rec  in tbl1_cur
                loop
                  begin
                    insert into tgt.tabl1(col1,col2,col3,col4)
                          values (   tbl1_cur_rec.col1,
                   tbl1_cur_reccol2,
                   tbl1_cur_rec.col3,
                   tbl1_cur_rec.col4);
                         -- REMOVED COMMIT, Commit outside or at the end.
                      exception
                         when others then
                           null; -- May be is better to (somehow) log the error ...
                  end;
                end loop;
          end;
    
    procedure mov_tbl2   is ...
    
    procedure mov_tbl3   is ...
    
    procedure mov_tbl4   is ...
    
    end;
    /
    

    You can call the procedure upd (calling others) this way:

    begin
      p.upd(true,false,true,false);
    end;
    /
    

    Update only table1 and table3.

    Max
    http://oracleitalia.WordPress.com

  • Sort order incorrect in datagrid sort multiple columns

    Hello

    I'm a little confused about sort multiple columns in a datagrid. The following code sorts, but not the sort, I expect or what you are doing the thing about a coming O alphabetically before or after P. In my opinion, the code must sort stadt, vname by clicking on the city column, and name, the VNAME by clicking on the column name, but obviously he disobeys correctly? You see an error in the code or is this a bug?

    <? XML version = "1.0" encoding = "utf-8"? >
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "vertical" >
    < mx:Script >
    <! [CDATA]
    Import mx.collections.SortField;
    Import mx.collections.Sort;
    Import mx.collections.ArrayCollection;
    Import mx.events.DataGridEvent;
    var myData: ArrayCollection collection = new ArrayCollection (new Array () collection
    {name: "Meier", vname: "Peter", City: "Bonn"},
    {name: "Meier", vname: "Max", City: "Bonn"},
    {name: "Meier", vname: "Olga", City: "Bonn"},
    {name: "Meier", vname: "Peter", City: "Bochum"},
    {name: "Meier", vname: "Susi", City: "Bochum"}
    ));
    function mySort(event:DataGridEvent) {}
    var mySorter: sort = new Sort();
    Switch (event.columnIndex) {}
    case 1:
    mySorter.fields =]
    new SortField ("name", true),
    new SortField ("vname", true)
    ];
    break;
    case 3:
    mySorter.fields =]
    new SortField ("stadt", true),
    new SortField ("name", true),
    new SortField ("vname", true)
    ];
    break;
    }
    myData.sort = mySorter;
    myData.refresh ();
    }
    []] >
    < / mx:Script >
    < mx:DataGrid dataProvider = '{myData}' headerRelease = "mySort (event)" >
    < mx:columns >
    < mx:DataGridColumn dataField = "name" headerText = "Name" / >
    < mx:DataGridColumn dataField = "VNAME" headerText = "Vorname" sortable = "false" / >
    < mx:DataGridColumn dataField = "stadt" headerText = "Stadt" / >
    < / mx:columns >
    < / mx:DataGrid >
    < / mx:Application >

    Allright! So the column index begins with zero don't step one! It was the first.

    Secondly, once you have defined your own sorter, you don't want the default behavior of the event to pass by so you will add

    Event.preventDefault ();

    just after myData.refresh (); line.

    Give it a shot. should work.

    HTH.

    ATTA

Maybe you are looking for

  • Partition missing Bootcamp after sleeping

    Hi guys,. I have the following problem. I have a Macbook Pro with OS X El Capitan 10.11.5 on it. I have multi boot, with 8.1 Windows it still works well, but I was in need of some extra HARD drive space on my OS X partition, so I was sleeping with a

  • Since the update last night (05/02/2013) we are unable to access the internet.

    My son says that there is an update last night when he was on the computer and the browser only, that we can use to access the internet now is Windows Internet Explorer. I tried all of the recommended patches and it still does not work.

  • Satellite P200 - 1 K 9 stuck / stuck on the Toshiba homepage

    Guys, can anyone help; last night I was downloading music from Napster and left the laptop to run while I went out.When I came back, I couldn't return to the vista system. The laptop gets as far as the Toshiba start page and is stuck / hanging there.

  • Issue of netflix Android TV KDL-43w800c.

    Recently bought this tv, specifically for netflix features. At the opening of the app, it brings me to the login screen. I go into the details, it goes back to loop connection, but returns just me at the first login screen. Already checked the connec

  • HP Notebook: Clean install Windows 7 on 15-ac048ca

    Hoping to install Windows 7 Ultimate on this machine. Problems with this notion? Thanks in advance...