Trying to convert multiple rows into multipe columns within a single row

I am trying to convert data from multiple rows into multiple columns. Let me see if I can paint the picture for you.
Here is a sample of the table i am trying to read from:
Company Name Account
1 Sam 123
1 Sam 234
1 Joe 345
1 Sue 789
1 Sue 987
1 Sue 573
I am trying to put this into a View that would have the data represented as such:
Company Name Acct1 Acct2 Acct3 Acct4
1 Sam 123 234 <null> <null>
1 Joe 345 <null> <null> <null>
1 Sue 789 987 573 <null>
Many thanks in advance for your help!

test@XE> --
test@XE> with t as (
  2    select 1 as company, 'Sam' as name, 123 as account from dual union all
  3    select 1, 'Sam', 234 from dual union all
  4    select 1, 'Joe', 345 from dual union all
  5    select 1, 'Sue', 789 from dual union all
  6    select 1, 'Sue', 987 from dual union all
  7    select 1, 'Sue', 573 from dual)
  8  --
  9  select company,
10         name,
11         max(case when rn = 1 then account else null end) as acct1,
12         max(case when rn = 2 then account else null end) as acct2,
13         max(case when rn = 3 then account else null end) as acct3,
14         max(case when rn = 4 then account else null end) as acct4
15    from (select company,
16                 name,
17                 account,
18                 row_number() over (partition by company, name order by 1) as rn
19            from t)
20   group by company, name;
   COMPANY NAM      ACCT1      ACCT2      ACCT3      ACCT4
         1 Joe        345
         1 Sam        234        123
         1 Sue        573        789        987
3 rows selected.
test@XE>
test@XE>isotope

Similar Messages

  • How to Transpose a Row into a Column ? (URGENT)

    I am trying to transpose a row into a column and please pay attention "Just one row of a table into a column of another table". Unlike Excel, in Numbers there is no easy way to transpose data but this is a bit urgent to me, any help would be appreciated!!!!

    Dear Friend,
    I have been looking for an answer the whole day and have performed every possible solution in the index, transpose, lookup and all the other recommended functions, none of them have worked for me in this case. I have gone through more than 20 posts on the discussion board but all of them were useless. I havent tried your method yet but although I appreciate your help and time, I dont remember forcing you or anyone else to help me, I just looked at posting my question  as an option to avoid writing long scripts for such a basic function that is easily available on excel under the special paste option.
    I thank you very much in advance for the advice.
    PS. I tried it and with a couple of modifications it worked, thank you very much for making my day
    Message was edited by: cool3pehr

  • Im trying to convert a PDF into an excel document and I keep getting an error message that reads "An error has occurred while trying to access the service". WHat am I doing wrong?

    Im trying to convert a PDF into an excel document and I keep getting an error message that reads "An error has occurred while trying to access the service". WHat am I doing wrong?

    it seems my subscription had expired so I signed up again.. It was still having trouble so I repeated the sign up process again.. Then it worked perfectly.. Unfortunately, I think I just subscribed twice and need to cancel one of them. Ugh. Such a pain when I'm trying to get this project completed. I'll be canceling at least one of the subscriptions in the morning. Adobe is not my favorite company right now. None of this was intuitive. And trying to get help was an absolute waste of an hour.
    Regards,
    Nathaniel
    [removed by moderator]

  • Select One Choice-select multiple attributes into mutiple columns

    Select One Choice-select multiple attributes into mutiple columns does not work.
    read-only view object view1 - columns a, b, c
    updatable view object view2 - also columns a, b, c
    Select One choice has the capability to bind multiple columns to multiple columns. I understand how this wizard is to be used for these multiple mappings, i.e., view2.a mapped to view1.a, view2.b mapped to view1.b, etc., and using 'select multiple...' for the display attribute. When I complete the 'List Binding Editor" correctly, in this example, only column a will be updated. Columns b,c, etc. will not be effected.
    Has anyone solved this? Please do not reply telling me how to use the editor, I know how, it just is not working.
    Here is my jspx segment,
    <af:selectOneChoice value="#{bindings.Eis000tv1SlOffice.inputValue}"
    label="#{bindings.Eis000tv1SlOffice.label}">
    <f:selectItems value="#{bindings.Eis000tv1SlOffice.items}"/>
    Here is pageDef segment:
    <list id="Eis000tv1SlOffice" IterBinding="Eis000tv1Iterator"
    StaticList="false" ListOperMode="0" ListIter="OfficeSpaceV1Iterator"
    NullValueFlag="1" NullValueId="Eis000tv1SlOffice_null">
    <AttrNames>
    <Item Value="SlOffice"/>
    <Item Value="Floor"/>
    <Item Value="FloorArea"/>
    </AttrNames>
    <ListAttrNames>
    <Item Value="SlOffice"/>
    <Item Value="Floor"/>
    <Item Value="Area"/>
    </ListAttrNames>
    <ListDisplayAttrNames>
    <Item Value="SlOffice"/>
    <Item Value="Floor"/>
    <Item Value="Area"/>
    </ListDisplayAttrNames>
    </list>
    Here is the iterator:

    can u set as specified here
    -Djps.app.credential.overwrite.allowed=true http://radalcove.com/blog/?p=34

  • I am trying to convert a PDF into a document that can be edited - it's a client feedback form. I am using Adobe forms Central and it's saying that it can't use my document.

    I am trying to convert a PDF into a document that can be edited - it's a client feedback form. I am using Adobe forms Central and it's saying that it can't use my document.

    Hi Michelle ,
    We are extremely sorry that you have had a bad experience with Adobe .
    As far as your issue is concerned ,Acrobat generally prompts for internet connection as it is required to activate the product before you could use it comfortably .Once the product is activated or licensed you would be able to use the software offline .
    This could be the possible reason you are experiencing this .Please check if you have done so and still facing this .And if you have not ,you need to license/activate your product by typing in your credentials ,i.e Adobe ID and password .
    You could also refer the following link to get updated about the activation of your product .
    https://helpx.adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html#a ctivate-how-to
    Regards
    Sukrit Dhingra

  • Adding Specific columns of dynamic internal table row into another column

    Hi Gurus,
    I need to add  few columns of a dynamic internal table row into another column:
    Article description hy01 hy02 total
    101      panza         10     12      22
    102      masht         12     12     24
    dynamic internal table is created and columns hy01 hy02.... can increase
    How to add the the values in hy01 hy 02... into total.
    Regards,
    Dep

    Hi,
    If you really want to have a dynamic table, then you will have to find a way to generate a whole new table, and then copy the data from the old table to the new one. There is no way to modify a type during runtime in ABAP.
    Here an example how to generate a dynamic table based on another internal table, hope this will help you.
    TYPE-POOLS: slis.
    PARAMETERS: p_nb_hy TYPE i DEFAULT 2. "Number of new HY columns to be added
    * Type ZST_T:
    *   matnr  TYPE matnr
    *   maktx  TYPE maktx
    *   hy01   TYPE i
    *   total  TYPE i
    TYPES: ty_t TYPE STANDARD TABLE OF zst_s.
    PERFORM main.
    *&      Form  main
    *       text
    FORM main.
      DATA: lt_fieldcat     TYPE slis_t_fieldcat_alv,
            lt_t            TYPE ty_t,
            lr_new_t        TYPE REF TO data.
      FIELD-SYMBOLS: <lt_new_t> TYPE STANDARD TABLE.
      "Add some lines to LT_T just to have something to display on screen
      DO 10 TIMES.
        APPEND INITIAL LINE TO lt_t.
      ENDDO.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'ZST_S'
        CHANGING
          ct_fieldcat      = lt_fieldcat.
      "Copy LT_T to LR_NEW_T
      PERFORM extend_and_copy_table USING lt_t p_nb_hy CHANGING lr_new_t lt_fieldcat.
      CLEAR lt_t. "Not needed anymore...
      ASSIGN lr_new_t->* TO <lt_new_t>.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_fieldcat = lt_fieldcat
        TABLES
          t_outtab    = <lt_new_t>.
    ENDFORM.                    "main
    *&      Form  extend_and_copy_table
    FORM extend_and_copy_table USING ut_t           TYPE STANDARD TABLE
                                     uv_nb_hy       TYPE i
                               CHANGING cr_t        TYPE REF TO data
                                        ct_fieldcat TYPE slis_t_fieldcat_alv
                               RAISING cx_sy_struct_creation cx_sy_table_creation.
      DATA: lo_tabledescr      TYPE REF TO cl_abap_tabledescr,
            lo_structdescr     TYPE REF TO cl_abap_structdescr,
            lo_new_structdescr TYPE REF TO cl_abap_structdescr,
            lo_new_tabledescr  TYPE REF TO cl_abap_tabledescr,
            lt_components      TYPE cl_abap_structdescr=>component_table,
            ls_component       TYPE cl_abap_structdescr=>component,
            lv_field_cnt       TYPE numc2,
            ls_fieldcat        TYPE slis_fieldcat_alv,
            lr_fieldcat        TYPE REF TO slis_fieldcat_alv.
      FIELD-SYMBOLS: <ls_old_s> TYPE ANY,
                     <lt_new_t> TYPE STANDARD TABLE,
                     <ls_new_s> TYPE ANY.
      "Get the list of all components from UT_T line structure
      lo_tabledescr  ?= cl_abap_tabledescr=>describe_by_data( ut_t ).
      lo_structdescr ?= lo_tabledescr->get_table_line_type( ).
      lt_components  = lo_structdescr->get_components( ).
      "The new columns will be from type of column HY01
      ls_component-type = lo_structdescr->get_component_type( 'HY01' ).
      "The new columns will have the same fieldcat info as column HY01
      READ TABLE ct_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'HY01'.
      "HY<lv_field_cnt> = new field name
      lv_field_cnt = uv_nb_hy + 1.
      "For each new column...
      DO uv_nb_hy TIMES.
        "Generate the new column field name
        CONCATENATE  'HY' lv_field_cnt INTO ls_component-name.
        ls_fieldcat-fieldname = ls_component-name.
        "Add the new field to the components of the new structure
        INSERT ls_component INTO lt_components INDEX 4.
        "Add the new field's fieldcat info to the fieldcat
        INSERT ls_fieldcat  INTO ct_fieldcat   INDEX 4.
        lv_field_cnt = lv_field_cnt - 1.
      ENDDO.
      "Adjust the COL_POS from fieldcat
      LOOP AT ct_fieldcat REFERENCE INTO lr_fieldcat.
        lr_fieldcat->col_pos = sy-tabix.
      ENDLOOP.
      "Create the new table
      lo_new_structdescr = cl_abap_structdescr=>create( p_components = lt_components ).
      lo_new_tabledescr  = cl_abap_tabledescr=>create( p_line_type = lo_new_structdescr ).
      CREATE DATA cr_t TYPE HANDLE lo_new_tabledescr.
      ASSIGN cr_t->* TO <lt_new_t>.
      "Copy all data from old to new table
      LOOP AT ut_t ASSIGNING <ls_old_s>.
        APPEND INITIAL LINE TO <lt_new_t> ASSIGNING <ls_new_s>.
        MOVE-CORRESPONDING <ls_old_s> TO <ls_new_s>.
      ENDLOOP.
    ENDFORM.                    "main

  • Hi, Im trying to convert a PDF into a weblink that I can post onto social media  but dont know how, can you help please?

    Hi, Im trying to convert a PDF into a weblink that I can post onto social media  but dont know how, can you help please?

    You need to upload it to some kind of public server, or file-sharing site (like Google Drive, Dropbox, etc.), and then post the link to it.

  • How do i convert multiple tracks into one large mp3?

    how do i convert multiple tracks into one large mp3?

    Hi,
    You can use an app such as Audacity or Join Together to create one larger file. If AAC file used instead of mp3, you could use GarageBand.
    If you have the original CD, you can join the tracks whilst re importing disc.
    Jim

  • Changing rows into different column names

    Hi,
    i need to tranpose the rows into differnent column names
    my sample data :
    id , val
    1 3
    1 4
    1 5
    into
    id , val1, val2 , val3 , val4 ... valn ..
    1 3 4 5
    from askTom's i see that it's tranpose into a single column using the ref cursor ?
    how can i do made it into different column names ?
    kindly advise
    tks & rdgs

    For example, lets say that you want to order your columns from least value to greatest and that you'll never have more than three values per id. Then you can use the analytic function row_number() like this to create a pivot value.
    select id, val,
           row_number() over (partition by id order by val) as rn
      from your_table;And so your pivot query ends up looking like this.
    select id,
           max(case when rn=1 then val end) AS val1,
           max(case when rn=2 then val end) AS val2,
           max(case when rn=3 then val end) AS val3
      from (
    select id, val,
           row_number() over (partition by id order by val) as rn
      from your_table
    group by id;But notice that I started out by making up answers to Justin's questions. You'll have to supply the real answers.

  • How could I insert the deleted row into another table within a trigger?

    Hi,
    How could I insert the deleted row into another table within a trigger? The destination table has the same columns as the source table. Since the statements are in the trigger, it is not allowed to query the source table named 'test'. Thanks! The trigger is as follows, uncompleted:
    CREATE TRIGGER delete_trigger
    AFTER DELETE
    ON test
    FOR EACH ROW
    BEGIN
    -- How could I insert the deleted row into another table
    END delete_trigger;
    Message was edited by:
    user569548

    Hi,
    I'm not sure what's wrong there.
    I read the oracle docs about ANALYZE and ALL_TAB_COLUMNS, and did the following:
    ANALYZE TABLE my_tab VALIDATE STRUCTURE; //went ok.
    SELECT column_name
    FROM all_tab_columns
    WHERE table_name = 'my_tab'; //but no rows selected?
    This topic might not be what this thread should be about. Here I posted a new thread:
    How to get colum names of the newly created table?
    Thanks.
    Message was edited by:
    user569548

  • How to aggregate a column based date column (for weekly single row)?

    How to aggregate a column based date column (for weekly single row)?

    Hi,
    Consider the below statement for daily bases which is ok
    SELECT ID, DATE, SUM(AMOUNT) FROM TABLE_NAME GROUP BY ID, DATE ORDER BY ID, DATE
    The same like the above statement, I want output on weekly, fortnightly, and monthly bases, How to do this? Need your help...

  • In the app "Numbers" I want to paste in many rows in to columns. And each row separated. Now it's getting all in one column

    In the app "Numbers" I want to paste in many rows in to columns. And each row separated. Now it's getting all in one column when I try to paste.
    Fact is that I have a 4 pages list with about 50 rows of single words and I want all that in columns

    Hey joshuafromisr,
    If you resintall iTunes, it should fix the issue. The following document will go over how to remove iTunes fully and then reinstall. Depending on what version of Windows you're running you'll either follow the directions here:
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    http://support.apple.com/kb/HT1925
    or here:
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    http://support.apple.com/kb/HT1923
    Best,
    David

  • How to display mutliple rows of database data in a single row

    We are using XML Publisher 5.6.2. We have a requirement, where we need to display a multiple database rows for a single column in a single row.
    Basically say a database column has 5 rows
    A1
    A2
    A3
    A4
    A5
    We want to display in the output in a single cell as
    A1 A2 A3 A4 A5
    Thanks,
    - Vasu -

    Look at this blog,
    http://blogs.oracle.com/xmlpublisher/2007/05/24#a325

  • I am trying to convert a pdf into an editable document

    I am trying to convert an adobe pdf into an editable document.

    Hey Leslie,
    If you don't have Acrobat installed on your computer than you can install 30 days free Trail version of Adobe Acrobat DC Pro using this link Download Adobe Acrobat free trial | Acrobat Pro DC.
    However if you want to contact Adobe Tech. Support please refer to this link Contact Customer Care, once the page gets loaded click on 'Still Need Help? Contact Us' button & initiate a Chat or Call.
    Regards,
    Aadesh

  • Function Module to convert multiple records into single record and vice-ver

    hi,
    i have a requirement to convert 10 records in an internal table to single record which should be passed
    to a single variable and store in the database.Kindly let me know is there any function module
    which meets my requirement. Also i need to do split one single record to 10 records each of
    say 65 length interval.
    kindly provide me if there is nay functinon module as such.
    I can do with ABAP-OOPS.Please suggest function module.

    I dont think such FM exists, but if you wanna code one it would be simple. Just loop through the internal table, keep concatenating the currently processing record into a long character variable to convert 10 records into one record.

Maybe you are looking for

  • Time Capsule connectivity issues with cable modem

    I have Comcast internet service (coming through a Linksys CM100 modem, no router) plugged directly to a 2TB dual-band TimeCapsule. In the past this has been working, and the TimeCapsule has been providing internet access to three Macs, as well as bac

  • Tagged text import issues

    I have had some issues with importing tagged text. In my workflow i get some data converted to tagged text, no problems, special characters are also converted to ASCII entities. Everything works on my machine, but as soon as it is imported on another

  • Migration from SQLServer

    I have to migrate a database from SQLServer 7.0 to Oracle 8i. I make it from the SQLServer console,and there's no problem.But there are some tables with several "Long" type fields,and there's an error showing me that Oracle only supports one "Long" f

  • IPod Mini only mounts with USB

    My daughter has 2 minis- Pink & Blue and she uses a G4 1G RAM, OS 10.3.9 She updated Pink using firewire, it synched fine. When she tried to update Blue, it wasn’t recognized. IPod software is up to date on both. Both fully charged, hold switch off,

  • How to get better than 5.2MB/s transfer rate from USB 2.0 on Mac Mini

    G'day, I've got a circa 2007 Mac Mini with 1GB of RAM, running Snow Leopard. Connected to this is a USB 2.0 500GB Seagate Freeagent drive from circa 2008. As far as I know, the USB disk is free of errors. I am trying to use dd with a block size of 1M