How to convert columns into rows using  transpose function

Hi
anybody tell me how to convert columns values into rows using transpose function.

Since BluShadow went to all the trouble to put it together, someone should use it.
See the post titled How do I convert rows to columns? here SQL and PL/SQL FAQ
John

Similar Messages

  • How to convert  columns into rows

    present result
    Mat_num        comp_code   disc          amount     
    800000     SG01      SAPLF005                    0.00
    800000     SG01      SAPLF005               31,500.00
    6300001    SPM       SAPLF005                    0.00
    6300001    SPM       SAPLF005              108,888.00
    APS100     SMTP      SAPLF005                    0.00
    APS100     SMTP      SAPLF005                    0.00
    required format
    Mat_num       disc             SG01          SMTP          SPM
    800000   SAPLF005   31,500.00           0.00          0.00
    800000   SAPLF005        0.00           0.00          0.00 
    6300001  SAPLF005        0.00         0.00     108,888.00     
    6300001  SAPLF005        0.00         0.00           0.00  
    APS100   SAPLF005        0.00         0.00           0.00 
    APS100   SAPLF005        0.00         0.00           0.00
    Plain Text Attachment [ Scan and Save to Computer ]
    REPORT  Z_CALC2                                 .
    TABLES : KNC1.
    TYPE-POOLS: SLIS.
      type-pools : abap.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: dy_table type ref to data,
          dy_line  type ref to data,
          xfc type lvc_s_fcat,
          ifc type lvc_t_fcat.
    DATA: BEGIN OF ITAB OCCURS 0,
              KUNNR LIKE KNC1-KUNNR,
              BUKRS LIKE KNC1-BUKRS,
              GJAHR LIKE KNC1-GJAHR,
              USNAM LIKE KNC1-USNAM,
              UMSAV LIKE KNC1-UMSAV,
          END OF ITAB.
    *Result table
    TYPES BEGIN OF RES_ITAB.
    * RES_ITAB(10) TYPE C DEFAULE 'ZRES_ITAB'.
    INCLUDE STRUCTURE ZRES_ITAB.
    TYPES END OF RES_ITAB.
    SELECT-OPTIONS : CCODE FOR KNC1-BUKRS DEFAULT 'SG01' TO 'SPM '.
    DATA : BEGIN OF COMP_ITAB OCCURS 0,
              BUKRS LIKE KNC1-BUKRS,
           END OF COMP_ITAB.
    DATA: COLS TYPE I,
          gap(10) TYPE c,
          Company_title type string .
    start-of-selection.
      perform get_NUM_COLS.
      perform get_structure.
      perform create_dynamic_itab.
      perform get_data.
    *  perform write_out.
    FORM GET_NUM_COLS.
    SELECT KUNNR BUKRS GJAHR USNAM UMSAV INTO TABLE ITAB FROM KNC1 WHERE
    BUKRS IN CCODE.
    CLEAR ITAB.
    *CLEAR RES_ITAB.
    LOOP AT ITAB .
         COMP_ITAB-BUKRS = ITAB-BUKRS.
         APPEND COMP_ITAB.
    CLEAR COMP_ITAB.
    ENDLOOP.
    SORT COMP_ITAB BY BUKRS.
    DELETE ADJACENT DUPLICATES FROM COMP_ITAB.
    DESCRIBE TABLE COMP_ITAB LINES COLS.
    ENDFORM.
    *Get table structure
    form get_structure.
    data : idetails type abap_compdescr_tab,
           xdetails type abap_compdescr.
    data : ref_table_des type ref to cl_abap_structdescr.
    data fld_pos type i value 1.
    * Get the structure of the table.
      ref_table_des ?=
                  cl_abap_typedescr=>describe_by_name( 'ZRES_ITAB' ).
      idetails[] = ref_table_des->components[].
      loop at idetails into xdetails.
        clear xfc.
        XFC-COL_POS = fld_pos.
        xfc-fieldname = xdetails-name .
        xfc-datatype = xdetails-type_kind.
        xfc-inttype = xdetails-type_kind.
        xfc-intlen = xdetails-length.
        xfc-decimals = xdetails-decimals.
        append xfc to ifc.
        fld_pos = fld_pos + 1.
      endloop.
      DO  COLS TIMES.
        clear xfc.
        READ TABLE COMP_ITAB INDEX SY-INDEX.
        XFC-COL_POS = fld_pos.
        xfc-fieldname = COMP_ITAB-BUKRS .
        xfc-datatype = 'F'.
    *    xfc-inttype = 'F'.   'details-type_kind.
        xfc-intlen = 14.
    *    xfc-decimals = xdetails-decimals.
        append xfc to ifc.
        fld_pos = fld_pos + 1.
      ENDDO.
      clear xfc.
        XFC-COL_POS = fld_pos.
        xfc-fieldname = 'RECORD_TOTAL' .
        xfc-datatype = 'F'.
        xfc-inttype  = 'F'.
        xfc-intlen = 14.
    *    xfc-decimals = xdetails-decimals.
        append xfc to ifc.
    endform.
    form create_dynamic_itab.
    * Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = ifc
                   importing
                      ep_table        = dy_table.
      assign dy_table->* to <dyn_table>.
    * Create dynamic work area and assign to FS
      create data dy_line like line of <dyn_table>.
      assign dy_line->* to <dyn_wa>.
    endform.
    form get_data.
    LOOP AT ITAB.
            <DYN_WA>-KUNNR = ITAB-KUNNR.
            <DYN_WA>-USNAM = ITAB-USNAM.
            DO COLS TIMES.
               IF <DYN_WA>
    DESCRIBE TABLE <dyn_table>.
    *WRITE:/ SY-TFILL.
    * Select Data from table.
    * <dyn_table> = ITAB[].
    *LOOP AT ITAB.
    *    RES-KUNNR = ITAB-KUNNR.
    *    RES-USNAM = ITAB-USNAM.
    *    CASE ITAB-GJAHR.
    *        WHEN 2005.
    *            RES-UMSAV1 = ITAB-UMSAV.
    *        WHEN 2006.
    *            RES-UMSAV2 = ITAB-UMSAV.
    *        WHEN 2007.
    *            RES-UMSAV3 = ITAB-UMSAV.
    *    ENDCASE.
    *    RES-TOTAL = RES-UMSAV1 + RES-UMSAV2 + RES-UMSAV3 .
    * APPEND RES.
    *ENDLOOP.
    endform.
    form write_out.
      loop at <dyn_table> into <dyn_wa>.
        do.
          assign component  sy-index
             of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <dyn_field>.
          else.
            write: <dyn_field>.
          endif.
        enddo.
      endloop.
    endform.
    Edited by: Alvaro Tejada Galindo on Feb 28, 2008 11:56 AM

    solved myself

  • To convert columns into row

    Hi All,
    I need help in building view which actually can show columns data as row.
    e.g.
    row is as follows
    Name Age Salary
    ABC 25 10000
    BBC 28 12000
    The above tables data I want to get as
    Name ABC BBC
    Age 25 28
    Salary 10000 12000
    Thanks in advance.

    Even if I don't really understand such requirement, I wrote some times ago such function to play around that :
    Re: Converting Columns into rows
    Nicolas.

  • How to turn columns into rows

    Hi. Does anyone know how to turn columns into rows ie:
    select field1, field2, field3, field4, field5 from table
    desired result:
    field1 field2
    field1 field3
    field1 field4
    field1 field5
    Thank you!

    Something like this ?
    select field1
    , case n.l
    when 1 then field2
    when 2 then field3
    when 3 then field4
    when 4 then field5
    end field
    from table
    , (select level l from dual connect by level <= 4) n

  • How to convert columns to rows

    I have 70 columns and I need to convert them into rows. Please help!
    Currently, it is showing as listed below
    message 1 message 2 message 3 message 4 message 5 .......... message 70
    system 1 20 10 40 60 100
    system 2 40 30 50 80 110
    system 3 60 60 70 90 120
    The desire output
    system 1 system 2 system 3
    message 1 20 40 60
    message 2 10 30 60
    message 3 40 50 70
    message 70

    Something like...
    SQL> ed
    Wrote file afiedt.buf
      1  select decode(rn,1,'Empno :'||empno
      2                  ,2,'Ename ('||empno||') :'||ename
      3                  ,3,'Job ('||empno||') :'||job
      4               ) as col
      5  from emp
      6       cross join (select rownum rn from dual connect by rownum <= 3)
      7* order by empno, rn
    SQL> /
    COL
    Empno :7369
    Ename (7369) :SMITH
    Job (7369) :CLERK
    Empno :7499
    Ename (7499) :ALLEN
    Job (7499) :SALESMAN
    Empno :7521
    Ename (7521) :WARD
    Job (7521) :SALESMAN
    Empno :7566
    Ename (7566) :JONES
    Job (7566) :MANAGER
    Empno :7654
    Ename (7654) :MARTIN
    Job (7654) :SALESMAN
    Empno :7698
    Ename (7698) :BLAKE
    Job (7698) :MANAGER
    Empno :7782
    Ename (7782) :CLARK
    Job (7782) :MANAGER
    Empno :7788
    Ename (7788) :SCOTT
    Job (7788) :ANALYST
    Empno :7839
    Ename (7839) :KING
    Job (7839) :PRESIDENT
    Empno :7844
    Ename (7844) :TURNER
    Job (7844) :SALESMAN
    Empno :7876
    Ename (7876) :ADAMS
    Job (7876) :CLERK
    Empno :7900
    Ename (7900) :JAMES
    Job (7900) :CLERK
    Empno :7902
    Ename (7902) :FORD
    Job (7902) :ANALYST
    Empno :7934
    Ename (7934) :MILLER
    Job (7934) :CLERK
    42 rows selected.

  • Converting columns into rows

    Dear all....I need to convert all columns into rows in a table. For example table has following columns:
    Emp_Cod........Val1......Val2......Val3
    1 a b c
    Now I wish that each column should display as a value like:
    Emp_Cod........Val1
    1 a
    1 b
    1 c
    Now the one way to solve this job is to write a union statement for each column but for this I'll have to write equal number of select statements as there are columns.
    What I need that is there anyway to write minimum code for this job, is there any alternate way???

    SQL> with t as(select 1 emp_code, 'a' val1, 'b' val2, 'c' val3 from dual)
      2  select*from t unpivot(v for c in(val1,val2,val3));
    EMP_CODE  C     V                                                      
            1  VAL1  a                                                      
            1  VAL2  b                                                      
            1  VAL3  c                                                      
    SQL> col COLUMN_VALUE for a20
    SQL> with t as(select 1 emp_code, 'a' val1, 'b' val2, 'c' val3 from dual)
      2  select*from t,table(sys.odcivarchar2list(val1,val2,val3));
    EMP_CODE  V  V  V  COLUMN_VALUE                                        
            1  a  b  c  a                                                   
            1  a  b  c  b                                                   
            1  a  b  c  c                                                   

  • How to convert column to row in 10g  and calculate the count

    876602 wrote:
    Hi ,
    i need to convert the column to row in my DB 10g , i cant use the Decode method because i have about 2000 items in MDN column
    this is sample of my date ,
    MDN             Date
    5C4CA98EABA3     20111205235240
    5C4CA98EABA3     20110925121833
    5C4CA98EABB0     20111025103700
    5C4CA98EABB0     20111124103700
    5C4CA98EABB5     20111030175717
    5C4CA98EABB8     20110925142653
    5C4CA98EABB8     20111126175853i need the result to be ,
    MDN             Date                                   count
    5C4CA98EABA3     20111205235240 ;  20110925121833    2
    5C4CA98EABB0     20111025103700 ;  20111124103700    2
    5C4CA98EABB5    20111030175717                      1
    5C4CA98EABB8   20110925142653 ; 20111126175853       2any help please ,
    Edited by: 876602 on 15/12/2011 01:33 ص

    SQL> with t as
      2  (
      3  select '5C4CA98EABA3' MDN ,'20111205235240' Dte  from dual
      4  union all
      5  select '5C4CA98EABA3','20110925121833' from dual
      6  union all
      7  select '5C4CA98EABB0','20111025103700' from dual
      8  union all
      9  select '5C4CA98EABB0','20111124103700' from dual
    10  union all
    11  select '5C4CA98EABB5','20111030175717' from dual
    12  union all
    13  select '5C4CA98EABB8','20110925142653' from dual
    14  union all
    15  select '5C4CA98EABB8','20111126175853' from dual
    16  )
    17  select mdn,ltrim(sys_connect_by_path(dte,';'),';') s,rw as "count"
    18  from
    19  (
    20  select mdn,dte,row_number() over(partition by mdn order by mdn) rw
    21  from t
    22  )
    23  where connect_by_isleaf = 1
    24  start with rw = 1
    25  connect by prior rw = rw-1
    26  and prior mdn = mdn
    27  ;
    MDN          S                                                                                     count
    5C4CA98EABA3 20111205235240;20110925121833                                                             2
    5C4CA98EABB0 20111025103700;20111124103700                                                             2
    5C4CA98EABB5 20111030175717                                                                            1
    5C4CA98EABB8 20110925142653;20111126175853                                                             2

  • How to convert column to row in 10g

    Hi ,
    i need to convert the column to row in my DB 10g , i cant use the Decode method because i have about 2000 items in MDN column
    this is sample of my date ,
    MDN             Date
    5C4CA98EABA3     20111205235240
    5C4CA98EABA3     20110925121833
    5C4CA98EABB0     20111025103700
    5C4CA98EABB0     20111124103700
    5C4CA98EABB5     20111030175717
    5C4CA98EABB8     20110925142653
    5C4CA98EABB8     20111126175853i need the result to be ,
    MDN             Date
    5C4CA98EABA3     20111205235240 ;  20110925121833 
    5C4CA98EABB0     20111025103700 ;  20111124103700
    5C4CA98EABB5    20111030175717
    5C4CA98EABB8   20110925142653 ; 20111126175853any help please ,
    Edited by: 876602 on 15/12/2011 01:33 ص

    Note the name of this forum is "SQL Developer *(Not for general SQL/PLSQL questions)*", so only for issues with the SQL Developer tool. Please post these questions under the dedicated {forum:id=75} forum.
    Regards,
    K.

  • How to split columns into rows

    Hi All,
    Below is my table structure:=
    SQL> create table split(id number,value varchar2(200));
    Table created.
    SQL> insert into split values(1,'X,Y,Z');
    1 row created.
    SQL> insert into split values(2,'A,B,C');
    1 row created.
    SQL> commit;
    Commit complete.
    Expected Output
    ID Value
    1 X
    1 Y
    1 Z
    2 A
    2 B
    3 C
    I know the feature of converting rows into columns by listagg in Oracle 11g, but is there any feature to convert rows into columns based on a delemiter..."," in my case.
    Please help....
    Thanks
    Arijit

    >
    is there any feature to convert rows into columns based on a delemiter
    >
    Here is one way
    VAR csv VARCHAR2(100)EXEC :csv := 'abc,de,fg,hij,klmn,o,pq,rst,uvw,xyz';
    The query:
    WITH data AS( SELECT SUBSTR(csv, INSTR(csv,',',1,LEVEL)+1,                     INSTR(csv,',',1,LEVEL+1) - INSTR(csv,',',1,LEVEL)-1 ) token    FROM ( SELECT ','||:csv||',' csv FROM SYS.DUAL ) CONNECT BY LEVEL < LENGTH(:csv)-LENGTH(REPLACE(:csv,',',''))+2 )SELECT token  FROM data;See http://projectwownow.blogspot.com/2010/02/oracle-convert-csv-string-into-rows.html

  • How to convert XML into XSD Using Altova XML Spy

    Hi,
    How to convert XML file into XSD Using Altova XML Spy.
    I want to use that XSD as an External Def in my IR
    Regards
    Suman

    hi
    Following is the path where you could get the PDF's and zip file.
    https://www.sdn.sap.com/irj/sdn/howtoguides?rid=/webcontent/uuid/5024a59a-4276-2910-7580-f52eb789194b [original link is broken]
    please check out the following Heading, and at the bottom corner you will find the download option where you will get the zip file:
    How to Generate XSD Schemas from Existing MDM 5.5 Repositories
    You can download xomlite45.jar from sdn
    copy the jar file to your java installation location like c:>java in
    Java –jar xomLite45.jar MyFile.xml
    then you get correspondig MyFile.xsd
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/bf0e8a97-0d01-0010-f0a2-af3b18b7f4eb

  • Split multiple columns into rows using XML

    Hi Forum,
    I am trying to split 2 columns that each contain values separated by semicolon into single rows. The relation between the values of the two columns is that the order in the cells corresponds to each other.
    The data looks like this:
    pk    Manufacturer                partnumber
    1     Man1; Man2;Man3      PN1;PN2;PN3
    2     Man4; Man2;Man5      PN4;PN5;PN6
    The result should be:
    pk    Manufacturer     partnumber
    1       Man1                   PN1
    1       Man2                   PN2
    1       Man3                   PN3
    2       Man4                   PN4
    2       Man2                   PN5
    2       Man5                   PN6
    I am not sure how to format the XML to get a useful Basis for XML.value or XML.query
    Any ideas?
    TIA
    Alex

    Hi,
    Try like this ,
    DECLARE @tmp TABLE (pk INT,Manufacturer NVARCHAR(50),partnumber NVARCHAR(50))
    INSERT @tmp SELECT 1,'Man1; Man2;Man3','PN1;PN2;PN3'
    INSERT @tmp SELECT 2,'Man4; Man2;Man5','PN4;PN5;PN6'
    SELECT * FROM @tmp
    SELECT tmp2.pk pk,Manufacturer,partnumber FROM (
    SELECT ROW_NUMBER()OVER(ORDER BY tmp1.pk) RN,* FROM (
    SELECT pk,
    LTRIM(i.value('.','varchar(100)')) Manufacturer
    FROM ( SELECT pk, Manufacturer,
    CONVERT(XML,'<r><n>'
    + REPLACE(Manufacturer,';', '</n><n>') + '</n></r>') AS X
    FROM @Tmp) Spt
    CROSS APPLY Spt.X.nodes('//*[text()]') x(i)
    ) tmp1 ) tmp2
    JOIN
    (SELECT ROW_NUMBER()OVER(ORDER BY pk) RN,* FROM (
    SELECT pk,
    j.value('.','varchar(100)') partnumber
    FROM ( SELECT pk, partnumber,
    CONVERT(XML,'<r><n>'
    + REPLACE(partnumber,';', '</n><n>') + '</n></r>') AS Y
    FROM @Tmp) Spt
    CROSS APPLY Spt.Y.nodes('//*[text()]') y(j)) tmp2 ) tmp3 ON tmp3.RN = tmp2.RN
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

  • Transporting columns into rows using SSIS

    Hi everyone,
    Just need some help.
    I wanna transpose a data table in SSIS.
    The table is originally 
    CUSTREFNO
    Citizen
    FORENAME
    Citizen
    SURNAME
    Citizen
    DATE-OF-BIRTH
    Citizen
    TEL_NO
    Citizen
    GUARDIANNAME
    Citizen
    ADDRESS1
    Citizen
    ADDRESS2
    Citizen
    ADDRESS3
    Citizen
    ADDRESS4
    Citizen
    POSTTOWN
    Citizen
    POSTCODE
    Citizen
    OPERATOR
    Junk
    BOARDINGPOINT
    Junk
    DESTINATION
    Junk
    SERVICE_NO
    Junk
    EMAIL
    Citizen
    And i need the table in the following format
    CUSTREFNO
    FORENAME
    SURNAME
    DATE-OF-BIRTH
    TEL_NO
    GUARDIANNAME
    ADDRESS1
    ADDRESS2
    ADDRESS3
    ADDRESS4
    POSTTOWN
    POSTCODE
    OPERATOR
    BOARDINGPOINT
    DESTINATION
    SERVICE_NO
    EMAIL
    Citizen
    Citizen
    Citizen
    Citizen
    Citizen
    Citizen
    Citizen
    Citizen
    Citizen
    Citizen
    Citizen
    Citizen
    Junk
    Junk
    Junk
    Junk
    Citizen
    Any help, would be very much appreciated, thanks

    Umar, please see these resources.
    http://blogs.msdn.com/b/philoj/archive/2007/11/10/transposing-rows-and-columns-in-sql-server-integration-services.aspx
    http://www.rad.pasfu.com/index.php?/archives/14-PIVOT-Transformation-SSIS-Complete-Tutorial.html
    http://dinesql.blogspot.in/2011/08/pivot-and-unpivot-integration-services.html
    http://sqlage.blogspot.in/2013/12/ssis-how-to-use-unpivot-in-ssis.html
    http://www.bimonkey.com/2009/06/the-pivot-transformation/
    http://www.sql-server-performance.com/2007/ssis-pivot-unpivot/
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • Convert columns into rows

    SQL>create table TEST1
    TRAIN_ID VARCHAR2(10) not null,
    ALIES VARCHAR2(15),
    VAL VARCHAR2(20)
    Now I insert data into test1 table.
    SQL> select* from test2;
    TRAIN_ID NAM DOB
    A ASHIS 11/11/1974
    B SOUGATA 20/06/1977
    Now how can I select data in the following
    output ? Please suggest me.
    TRAIN_ID ALIES VAL
    A NAM ASHIS
    A DOB 11/11/1974
    B NAM SOUGATA
    B DOB 20/06/1977

    SELECT *
      FROM(
    SELECT tran_id, 'NAM' alies, nam val
      FROM test2
    UNION ALL
    SELECT tran_id, 'DOB' alies, TO_CHAR(dob, 'DD/MM/YYYY') val
      FROM test2
    ORDER BY tran_idwould appear to do what you want, though I'm not sure why you'd want it. Note that you'll have to convert all the values to a single data type (in this case VARCHAR2), which would make operating on the data quite painful later on...
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Convert Column to rows using  sql

    My client relies on a legacy system which currently outputs data in the following format:
    001
    100test1
    110addr1
    115addr2
    120city
    125state
    999drr
    001
    100test1
    110addr1
    115addr2
    120city
    125state
    130XXX
    135YYY
    140ZZZ
    999drr
    001
    100test1
    110addr1
    115addr2
    120city
    125state
    145AAA
    150BBB
    155CCC
    999drr
    I want to transform the above data into the format, as shown below:
    Name | ADDR1 | ADDR2 | CITY | STATE | ColX | ColY | ColZ | ColA | ColB | ColC | .... | LastCol
    100test1 | 110addr1 | 115addr2 | 120city | 125state | null | null | null | null | null | null | ... | null
    100test1 | 110addr1 | 115addr2 | 120city | 125state | 130XXX | 135YYY | 140ZZZ | null | null | null | ... | null
    100test1 | 110addr1 | 115addr2 | 120city | 125state | null | null | null | 145AAA| 150BBB | 155CCC | ... |null |
    When I tried , it only works when the number of rows between '001' and '999' is fixed. But, in my case, the data I get is never fixed and there can be any number of rows in betweeen '001' and '999' and The rows with null values do not show up at all in the flatfile (as shown above in the third block).
    Can anyone help about how to achieve this kind of data transformation ? What sequence of steps or scripts do I have to run to get this?
    Any help is appreciated.
    Thanks ahead
    prema

    I have considered that 7 consecutive rows forms one record. Change the 7 in the query according to your actual data.
    SQL> with t
      2  as
      3  (
      4  select '001' detail from dual
      5  union all
      6  select '100test1' from dual
      7  union all
      8  select '110addr1' from dual
      9  union all
    10  select '115addr2' from dual
    11  union all
    12  select '120city' from dual
    13  union all
    14  select '125state' from dual
    15  union all
    16  select '999drr' from dual
    17  union all
    18  select '002' from dual
    19  union all
    20  select '200test2' from dual
    21  union all
    22  select '210addr1' from dual
    23  union all
    24  select '215addr2' from dual
    25  union all
    26  select '220city' from dual
    27  union all
    28  select '225state' from dual
    29  union all
    30  select '999drr' from dual
    31  union all
    32  select '003' from dual
    33  union all
    34  select '300test1' from dual
    35  union all
    36  select '310addr1' from dual
    37  union all
    38  select '315addr2' from dual
    39  union all
    40  select '320city' from dual
    41  union all
    42  select '325state' from dual
    43  union all
    44  select '999drr' from dual
    45  )
    46  select ltrim(max(sys_connect_by_path(detail,'|')),'|')
    47  from
    48  (
    49         select row_num,
    50                trunc(abs(decode(row_num-rownum,0,1,row_num-rownum))/7)+1 row_num1,
    51                detail
    52      from
    53          (
    54          select decode(mod(rownum,7),0,7,mod(rownum,7)) row_num,detail
    55          from t
    56          )
    57  )
    58  start with row_num=1
    59  connect by row_num-1=prior row_num
    60  and row_num1= PRIOR row_num1
    61  group by row_num1
    62  /
    LTRIM(MAX(SYS_CONNECT_BY_PATH(DETAIL,'|')),'|')
    001|100test1|110addr1|115addr2|120city|125state|999drr
    002|200test2|210addr1|215addr2|220city|225state|999drr
    003|300test1|310addr1|315addr2|320city|325state|999drrRegards,
    Mohana

  • Convert Columns into Rows (internal tables) - Urgent Help Pleasse..

    Hi friends i'm having a little problem and hope you can help me..Here's the situation.
    I have an internal table like shown below
    (Key)                   (Key)               (Key)          (Key)
    PATH_ID     |      GROUP     |      LINE     |     ATRIBUTE          |    VALUE
    ASLN2                1                      1                Company_Code       5146
    ASLN2                1                      1                Account_Code        400405
    ASLN2                1                      1                Profit_Centre          AA00N2
    ASLN2                1                      2                Company_Code       5146
    ASLN2                1                      2                Account_Code       400705
    ASLN2                1                      2                Profit_Centre          AA00N2
    ASLN3                1                      1                Company_Code       5146
    ASLN3                1                      1                Account_Code        400405
    ASLN3                1                      1                Profit_Centre          AA00N2
    ASLN3                1                      2                Company_Code       5146
    ASLN3                1                      2                Account_Code       400705
    ASLN3                1                      2                Profit_Centre          AA00N2
    and i want to convert this internal table to one like below
    PATH_ID      |      GROUP      |      LINE     |      Company Code   |    Account Code    |    Profit Centre
    ASLN2                1                      1                 5146                     400405                   AA00N2
    ASLN2                1                      2                 5146                     400705                   AA00N2
    ASLN3                1                      1                 5146                     400405                   AA00N2
    ASLN3                1                      2                 5146                     400705                   AA00N2
    but i'm a bit of stuck, all those key fields are making me confused...anyone have a marvelous ( ) idea of how to implement this transformation ?
    best regards,
    Ricardo Monteiro

    Itab1 with the structure PATH_ID | GROUP | LINE | ATRIBUTE | VALUE
    Itab2 with structure PATH_ID | GROUP | LINE | ATRIBUTE | VALUE
    Itab3 with the final structure PATH_ID | GROUP | LINE | Company Code | Account Code | Profit Centre
    move itab1 to itab2.
    sort itab2 by path_id group line.
    delete adjacent duplicates from itab2 comparing path_id group line.
    loop at itab2.
      clear itab3.
      move:
         itab2-pathid to itab3-pathid,
         itab2-group to itab3-group,
         itab2-line to itab3-line.  
      loop at itab1where pathid = itab2-pathid
                            and group = itab2-group
                            and line   = itab2-line.
          IF itab1-ATRIBUTE = ' Company_Code'.
             itab3-Company_Code = itab1-attribute.
          elseif itab1-ATRIBUTE = ' Account_Code '.
             itab3-Account_Code = itab1-attribute.
          elseif itab1-ATRIBUTE = ' Profit_Centre ' .
             itab3-profit_center = itab1-attribute.
          endif
      endloop.
      append itab3.
    endloop.
    try this.
    Thanks,
    rajinikanth

Maybe you are looking for

  • Java web application will not run on iMac.

    I have a problem that has defied technical support in 2 organisations. I am a stock trader and use a high spec iMac for my trading platforms. Recently I tried to run two different trading platforms on my Mac without success. The applications are Thin

  • Loss of sound half way through playing a vid clip

    Hi there people. Wonder if you can help. I have had my awsome N95 for a month now and have just loaded the nokia suite. I have sent video clips ranging from 4 seconds to 3 minutes to the phone that were taken on a Samsung 8mp camera but after exactly

  • I want to display parked invoices in the PO History tab.

    I want to see the parked invoices in the PO history tab. Is there a way to pull this in? It does not show up on there currently. Thanks! Chris Lintner Aflac

  • Smart form print preview in PDF format

    Hi ABAP Experts, I have 2 requirements 1) I want to print preview of a smartform in pdf format 2) I also want to attach a local pdf file to the smartform which is displaying in the pdf print preview format or to rephrase: I want a pdf attached to a s

  • Webservice not returning a String

    I am running this block of code against an asp.net web service. When I test the service through Internet Explorer, it returns; <string xmlns=" http://tempuri.org/">Success</string> So I know its return "Success" as a String. I created wsOwners as a S