Converting a single row into multiple columns

Hi All,
I have a hierarchy table. Sample values are
Parent Child
1
1 2
1 3
2 4
3 5
2 6
I have used the connect by clause to get the following listing using sys_connect_by_path
/1/
/1/2/
/1/3/
/1/2/4/
/1/2/6/
/1/3/5/
But now I need them in seperate columns like
c1 c2 c3
1
1 2
1 3
1 2 4
1 2 6
1 3 5
Please help me in getting this resultset.
Thanks
Subbu S

SQL> create table hierarchy_table
  2  as
  3  select 1 parent, 2 child from dual union all
  4  select null, 1 from dual union all
  5  select 1, 3 from dual union all
  6  select 2, 4 from dual union all
  7  select 3, 5 from dual union all
  8  select 2, 6 from dual
  9  /
Tabel is aangemaakt.
SQL> column s format a30
SQL> column c1 format a5
SQL> column c2 format a5
SQL> column c3 format a5
SQL> select s
  2       , substr
  3         ( s
  4         , nullif(instr(s,'|',1,1),0) + 1
  5         , nvl(nullif(instr(s,'|',1,2),0),4000) - instr(s,'|',1,1) - 1
  6         ) c1
  7       , substr
  8         ( s
  9         , nullif(instr(s,'|',1,2),0) + 1
10         , nvl(nullif(instr(s,'|',1,3),0),4000) - instr(s,'|',1,2) - 1
11         ) c2
12       , substr
13         ( s
14         , nullif(instr(s,'|',1,3),0) + 1
15         , nvl(nullif(instr(s,'|',1,4),0),4000) - instr(s,'|',1,3) - 1
16         ) c3
17    from ( select sys_connect_by_path(child,'|') s
18             from hierarchy_table
19          connect by parent = prior child
20            start with parent is null
21         )
22  /
S                              C1    C2    C3
|1                             1
|1|2                           1     2
|1|2|4                         1     2     4
|1|2|6                         1     2     6
|1|3                           1     3
|1|3|5                         1     3     5
6 rijen zijn geselecteerd.Regards,
Rob.

Similar Messages

  • Merge multiple rows into single row (but multiple columns)

    How to merge multiple rows into single row (but multiple columns) efficiently.
    For example
    IDVal IDDesc IdNum Id_Information_Type Attribute_1 Attribute_2 Attribute_3 Attribute_4 Attribute_5
    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
    65 affc 2 Location USA TX AUS Hilton 92305
    65 affc 2 Stats 5510 42.7 46 9999
    65 affc 2 Audit 1996 July 172 1100
    where different attributes mean different thing for each Information_type.
    For example for Information_Type=Location
    Attribute_1 means Country
    Attribute_2 means State and so on.
    For example for Information_Type=Stats
    Attribute_1 means Population
    Attribute_2 means American Ethnicity percentage and so on.
    I want to create a view that shows like below:
    IDVal IDDesc IDNum Country State City Hotel ZipCode Population American% Other% Area Audit Year AuditMonth Audit Type AuditTime
    23 asdc 1 USA NM ABQ FourSeasons 87106 2300 91.7 46 85432 1996 June 17 1200
    65 affc 2 USA TX AUS Hilton 92305 5510 42.7 46 9999 1996 July 172 1100
    Thanks

    Hi,
    That's called Pivoting . The forum FAQ has a section on this subject: {message:id=9360005}
    I hope this answers your question.
    If not, post your best attempt, along with a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data. (You did post the results you wanted, but they're very hard to read because they're 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}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Convert one record row into multiple rows

    Hi,
       I have small requirement.I have selected one data base record into an internal table.Now internal table has 1 record i.e 1 row(ex: 10 columns). Now i will convert this single row record into multiple  records i.e 10 rows( 10 columns wil; be converted into 10 rows). How i will convert this. Please give me any idea on this.
    Regards
    Geetha

    Hi Geetha,
    Search SCN using keyword,  " convert Rows into columns" or vice versa,,,
    U will get more answers & solutions,
    Look at Some of the Previous threads....
    Re: How to create a structure of itab as rows as colums and columns rows dy
    Re: Transpose rows and columns
    CONVERT ROWS INTO COLUMNS IN INTERNAL TABLE
    Convert Internal table Rows into columns of another internal table
    how to convert columns of an internal table to rows of another internal tab.
    Convert Columns into Rows (internal tables) - Urgent Help Pleasse..
    converting columns to rows
    Thanks & regards,
    Dileep .C

  • Split single row into multiple rows containing time periods

    Hi,
    I have a table with rows like this:
    id, intime, outtime
    1, 2010-01-01 00:10, 2010-01-3 20:00
    I would like to split this row into multiple rows, 1 for each 24hr period in the record.
    i.e. The above should translate into:
    id, starttime, endtime, period
    1, 2010-01-01 00:10, 2010-01-02 00:10, 1
    1, 2010-01-02 00:10, 2010-01-03 00:10, 2
    1, 2010-01-03 00:10, 2010-01-03 20:00, 3
    The first starttime should be the intime and the last endtime should be the outtime.
    Is there a way to do this without hard-coding the 24hr periods?
    Thanks,
    Dan Scott
    http://danieljamesscott.org

    Thanks for all the feedback, Dan.
    It appears that the respective solutions provided will give you: a) different resultsets and b) different performance.
    Regarding your 'truly desired resultset' you haven't answered all questions from my previous post (there are differences in the provided examples), but anyway:
    I found that using CEIL or ROUND makes quite a difference, using my 'simple 3 record testset' (30 records vs. 66 records got initially returned, that's less than half of the original). That's quite a difference. However, I must call it a day (since it's almost midnight) for now, so there's room for more optimizement and I haven't thoroughly tested.
    But this might hopefully make a difference performancewise when compared to my previous 'dreaded example':
    SQL> drop table t;
    Table dropped.
    SQL> create table  t as
      2  select 1 id, to_date('2010-01-01 00:10', 'yyyy-mm-dd hh24:mi') intime, to_date('2010-01-03 20:00', 'yyyy-mm-dd hh24:mi') outtime from dual union all
      3  select 2 id, to_date('2010-02-01 00:10', 'yyyy-mm-dd hh24:mi') intime, to_date('2010-02-05 20:00', 'yyyy-mm-dd hh24:mi') outtime from dual union all
      4  select 3 id, to_date('2010-03-01 00:10', 'yyyy-mm-dd hh24:mi') intime, to_date('2010-03-03 00:10', 'yyyy-mm-dd hh24:mi') outtime from dual;
    Table created.
    SQL> select id
      2  ,      max(intime)+level-1 starttime
      3  ,      case
      4           when level = to_char(max(t.outtime), 'dd')
      5           then max(t.outtime)
      6           else max(t.intime)+level
      7         end outtime
      8  ,      level period      
      9  from   t
    10  connect by level <= round(outtime-intime)
    11  group by id, level
    12  order by 1,2;
            ID STARTTIME           OUTTIME                 PERIOD
             1 01-01-2010 00:10:00 02-01-2010 00:10:00          1
             1 02-01-2010 00:10:00 03-01-2010 00:10:00          2
             1 03-01-2010 00:10:00 03-01-2010 20:00:00          3
             2 01-02-2010 00:10:00 02-02-2010 00:10:00          1
             2 02-02-2010 00:10:00 03-02-2010 00:10:00          2
             2 03-02-2010 00:10:00 04-02-2010 00:10:00          3
             2 04-02-2010 00:10:00 05-02-2010 00:10:00          4
             2 05-02-2010 00:10:00 05-02-2010 20:00:00          5
             3 01-03-2010 00:10:00 02-03-2010 00:10:00          1
             3 02-03-2010 00:10:00 03-03-2010 00:10:00          2
    10 rows selected.
    SQL> By the way: I'm assuming you're on 10g, is that correct?
    Can you give us some information regarding the indexes present on your table?

  • Split one row into multiple columns

    Hi,
    Data in one CLOB column in a table storing with delimiter, ##~~##. Ex. ##~~##abc##~~##defgh##~~##ijklm##~~##nopqr (data starts with delimiter). Please help me to split the data into multiple rows like below and it should be in the same order.
    abc
    defgh
    ijklm
    nopqr
    I am using Oracle 11g.
    Thanks.

    Thanks Hoek for your response. Before posting my question in the forum, I tried similar query. It is working with one character as delimiter.
    with test as (select 'ABC,DEF,GHI,JKL,MNO' str from dual )
    select regexp_substr (str, '[^,]+', 1, rownum) split
    from test
    connect by level <= length (regexp_replace (str, '[^,]+')) + 1;
    Above query is giving correct result by fetching 5 rows. I have modified the query like below...
    with test as (select 'ABC,,,DEF,,,GHI,,,JKL,,,MNO' str from dual )
    select regexp_substr (str, '[^,,,]+', 1, rownum) split
    from test
    connect by level <= length (regexp_replace (str, '[^,,,]+')) + 1;
    Above query resulting 13 rows and last 8 rows are nulls. Number of null rows are increasing, if I increase number of characters in delimiter. Could you please tell me how to avoid those null rows.
    Thanks.

  • One Row into multiple Column

    CREATE TABLE #ids (empid VARCHAR(200))
    INSERT INTO #ids SELECT '100,200,300,400'
    INSERT INTO #ids SELECT '1100,1200,1300,1400'
    I am trying to get output following format
    ID_1    ID_2   ID_3  ID_4
    100     200    300   400
    1000    1200   1300  1400
    Each row in EmpId column will have only max. four values
    Thanks
    V

    One more method:
    CREATE TABLE #ids (empid VARCHAR(200))
    INSERT INTO #ids SELECT '100,200,300,400'
    INSERT INTO #ids SELECT '1100,1200,1300,1400'
    select * from #ids
    ;WITH
    L0 AS(SELECT 1 AS c UNION ALL SELECT 1),
    L1 AS(SELECT 1 AS c FROM L0 AS A, L0 AS B),
    L2 AS(SELECT 1 AS c FROM L1 AS A, L1 AS B),
    L3 AS(SELECT 1 AS c FROM L2 AS A, L2 AS B),
    Numbers AS(SELECT ROW_NUMBER() OVER(ORDER BY c) AS n FROM L3)
    SELECT [1] AS Column1, [2] AS Column2, [3] AS Column3, [4] AS Column4
    FROM
    (SELECT rn,
    ROW_NUMBER() OVER (PARTITION by rn ORDER BY nums.n) AS PositionInList,
    LTRIM(RTRIM(SUBSTRING(valueTable.empid, nums.n,
    charindex(N',', valueTable.empid + N',', nums.n) - nums.n))) AS [Value]
    FROM Numbers AS nums INNER JOIN (Select row_number()over (Order by (Select NULL)) rn , Empid From #ids) AS valueTable ON nums.n <= CONVERT(int, LEN(valueTable.empid))
    AND SUBSTRING(N',' + valueTable.empid, n, 1) = N',') AS SourceTable
    PIVOT
    MAX([VALUE]) FOR PositionInList IN ([1], [2], [3], [4])
    ) AS Table2
    drop table #ids

  • How to transpose rows into multiple columns using pivot table

    I have 1 row containing 12 columns with value "JAN", "FEB", "MAR", "J-1","F-1","M-1","J-2","F-2","M-2","J-3","F-3","M-3"
    I want to display as
    JAN J-1 F-1 M-1
    FEB J-2 F-2 M-2
    MAR J-3 F-3 M-3
    How do I achieve the above?

    Today you have only 3 months JAN, FEB, MAR. Is it always the same number of columns. What if there are more months added to this row?
    Is your data really coming from relational source or some sort of text file?
    There is a better way to do this in narrative view using HTML if your requirement is just to show them in multiple rows and do some calculations.
    Go to Narrative View;
    In prefix, use <html> <table>
    In 'Narrative' text box add something like this
    <tr> <td> @1 </td> <td> @4 </td> <td> @7 </td> </tr>
    <tr> <td> @2 </td> <td> @5 </td> <td> @8 </td> </tr>
    <tr> <td> @3 </td> <td> @6 </td> <td> @9 </td> </tr>
    In Suffix, use </table> </html>
    You can also add simple calculations like sum etc at the very bottom of these rows as grand totals.
    kris

  • Display rows into multiple columns

    I have a table in the following format:
    id value
    a1 0
    a2 0
    a3 0
    a4 0
    b1 0
    b2 0
    b3 0
    b4 0
    how do I go about displaying it into four columns in the following format:
    id1 value1 id2 value2
    a1 0 b1 0
    a2 0 b2 0
    a3 0 b3 0
    a4 0 b4 0

    Hi,
    789063 wrote:
    I got that error in toad. So now I am testing from command prompt. When you say "command prompt", do you mean SQL*Plus?
    Sorry, I don't know much about Toad. If Toad is returning 0 rows, and the same query is returning 8 rows in SQL*Plus, then I suspect you are not connecting to the same database or the same user. ASre you sure you're running the exact same query in both front ends?
    Here is the data set that I am testing for:
    <pre>
    id1 value
    smple_val_1 0
    smple_val_2 1
    smple_val_3 1
    smple_val_4 2
    smple_other_1 3
    smple_other_2 5
    smple_other_3 8
    smple_other_4 13
    some_other_val1 1
    some_other_val2 0
    some_other_val3 3
    some_other_val4 5
    </pre>
    I am trying to select only 'smple%' in the query, which should display in four columns like:
    <pre>
    id1 val1 id2 val2
    smple_val_1 1 smple_other_1 3
    smple_val_2 0 smple_other_2 5
    smple_val_3 0 smple_other_3 8
    smple_val_4 2 smple_other_4 13
    </pre>Is that really the output you want? Why not
    ID1             VAL1 ID2             VAL2
    smple_val_1        0 smple_other_1      3
    smple_val_2        1 smple_other_2      5
    smple_val_3        1 smple_other_3      8
    smple_val_4        2 smple_other_4     13with the 0's and 1's in the val1 column reversed?
    Here is the ddl I used:
    <pre>
    CREATE TABLE     table_x
    ( id     VARCHAR2 (20)     PRIMARY KEY
    , value     NUMBER
    INSERT INTO table_x (id, value) VALUES ('smple_val_1', 0);
    INSERT INTO table_x (id, value) VALUES ('smple_val_2', 1);
    INSERT INTO table_x (id, value) VALUES ('smple_val_3', 1);
    INSERT INTO table_x (id, value) VALUES ('smple_val_4', 2);
    INSERT INTO table_x (id, value) VALUES ('smple_other_1', 3);
    INSERT INTO table_x (id, value) VALUES ('smple_other_2', 5);
    INSERT INTO table_x (id, value) VALUES ('smple_other_3', 8);
    INSERT INTO table_x (id, value) VALUES ('smple_other_4', 13);
    INSERT INTO table_x (id, value) VALUES ('some_other_val1', 1);
    INSERT INTO table_x (id, value) VALUES ('some_other_val2', 0);
    INSERT INTO table_x (id, value) VALUES ('some_other_val3', 3);
    INSERT INTO table_x (id, value) VALUES ('some_other_val4', 5);
    </pre>Thanks, that's good.
    Where is the explanation of how you get the results you want from that data? There are a lot of different ways to get the same results from the same data, especially from a small set of sample data. I might provide a query that gets the right results for the wrong reasons, and when you run that query on a different set of data, it won't necessarily work. That's exactly what happened before. I guessed at what you wanted, but I guessed wrong. Guessing is not a very efficient or reliable way to solve problems. Don't make people guess: explain what you want.
    In particular, explain how you can tell, buy looking at a row and column in the original table, to which row and which column of the output it corresponds. I'm pretty sure that the id column of the table always corresponds to either the id1 or idl2 column of the output, and that value always corresponds to either val1 or val2. From this latest set of sample data, it looks like all the rows in table_x that start with 'smple_val' will correspond to the id1 and val1 columns, and that all therows that start with 'smple_other_' will correspond to the id2 and val2 columns. It also looks like each row of the output represents a unique value of the last character of table_x.id.
    If I guessed right this time, then what you want is:
    SELECT       MIN (CASE WHEN id LIKE 'smple\_val\_%'   ESCAPE '\' THEN id    END)     AS id1
    ,       MIN (CASE WHEN id LIKE 'smple\_val\_%'   ESCAPE '\' THEN value END)     AS val1
    ,       MIN (CASE WHEN id LIKE 'smple\_other\_%' ESCAPE '\' THEN id    END)     AS id2
    ,       MIN (CASE WHEN id LIKE 'smple\_other\_%' ESCAPE '\' THEN value END)     AS val2
    FROM       table_x
    GROUP BY  SUBSTR (id, -1)
    ORDER BY  SUBSTR (id, -1)
    ;But this is only a guess. I can't guarrantee that this will work on your real data any better than my last guess did. You'll get better answers faster if you provide an explanation, so that poeple don't have to guess so much.

  • Converting a single edition into Multiple edition

    I have created a single edition ipad app (Game Drive - A Safari Guide), which is selling well. But now I want to create an iphone app multiple edition app. I submitted the iphone app, but Apple rejected it as they say that it is not compatible with ipad. So to be able to have an iphone app, I have to have an ipad version of the same app. My problem is that it is the same app, i.e. if I have a multiple edition app called Game Drive, it will be the same as the single edition app that I already have on the app store.
    My questions are: 1. What is the tendancy - do people buy multiple edition apps more, or single editions? i.e. will I loose out if I convert to a multiple edition app on my ipad?
    2. If I keep the single edition of the app on the app store for the ipad, will people get confused because there are two apps with the same name? Has anybody done that before?
    3. Is it worthwhile putting it on newsstand?
    My existing app is selling quite well, and don't want to mess with something that works. But to be able to create an iphone app, I have to have a multiple ipad app of the same thing.
    Can someone give some advice please?

    SQL> create table hierarchy_table
      2  as
      3  select 1 parent, 2 child from dual union all
      4  select null, 1 from dual union all
      5  select 1, 3 from dual union all
      6  select 2, 4 from dual union all
      7  select 3, 5 from dual union all
      8  select 2, 6 from dual
      9  /
    Tabel is aangemaakt.
    SQL> column s format a30
    SQL> column c1 format a5
    SQL> column c2 format a5
    SQL> column c3 format a5
    SQL> select s
      2       , substr
      3         ( s
      4         , nullif(instr(s,'|',1,1),0) + 1
      5         , nvl(nullif(instr(s,'|',1,2),0),4000) - instr(s,'|',1,1) - 1
      6         ) c1
      7       , substr
      8         ( s
      9         , nullif(instr(s,'|',1,2),0) + 1
    10         , nvl(nullif(instr(s,'|',1,3),0),4000) - instr(s,'|',1,2) - 1
    11         ) c2
    12       , substr
    13         ( s
    14         , nullif(instr(s,'|',1,3),0) + 1
    15         , nvl(nullif(instr(s,'|',1,4),0),4000) - instr(s,'|',1,3) - 1
    16         ) c3
    17    from ( select sys_connect_by_path(child,'|') s
    18             from hierarchy_table
    19          connect by parent = prior child
    20            start with parent is null
    21         )
    22  /
    S                              C1    C2    C3
    |1                             1
    |1|2                           1     2
    |1|2|4                         1     2     4
    |1|2|6                         1     2     6
    |1|3                           1     3
    |1|3|5                         1     3     5
    6 rijen zijn geselecteerd.Regards,
    Rob.

  • Multiplex single row into multiple rows

    Hi guys,
    could you please help me with preparing a select statement.
    Table sales:
    product name transaction
    x laptop 3
    y mobile 2
    z charger 4
    consider we have the table structure as above.
    i need a select query, that gives the result as below
    product name transaction
    x laptop 1
    x laptop 1
    x laptop 1
    y mobile 1
    y mobile 1
    z charger 1
    z charger 1
    z charger 1
    z charger 1
    here the ransactions are divided into several records based on the transaction.
    Thanks
    Karthee

    Hi Karthee,
    Welcome to the forum !!!
    Try this...
    with xx as(
      select 'x' p,'laptop' n,3 t from dual union all
      select 'y' p,'mobile' n,2 t from dual union all
      select 'z' p,'charger' n,4 t from dual
    select t1.p ,t1.n, 1 from (
       select p,n,row_number() over(partition by p,n order by p) rn from xx
         connect by level<=t) t1, xx
    where rn<= xx.t and xx.p = t1.p;gives
    o/p =
    x     laptop     1
    x     laptop     1
    x     laptop     1
    y     mobile     1
    y     mobile     1
    z     charger     1
    z     charger     1
    z     charger     1
    z     charger     1Ranit B.
    Edited by: ranit B on Nov 24, 2012 9:30 PM
    -- added o/p

  • 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

  • Displaying single value (Record) into multiple columns

    Hi All,
    I want to display the single record into multiple columns. Please let me know How to achieve this..
    Record:
    Lvl Activity Acre
    6 Week 4 (Same value to be displayed into 3 columns.)
    REquired output:
    lvl Activity PH1 PH2 PH3
    6 Week 4 4 4
    Thanks
    Kavi

    user533671 wrote:
    Hi,
    Thanks for immediate reply.
    PH1, PH2, PH3, ... will go more columns based on parameter , what we are passing.An single SQL statement cannot have a dynamic number of columns based on the data itself. The projection (columns returned) have to be known before any data is fetched... and that includes some 'parameter' value.
    {thread:id=2309172}
    You can build a query dynamically, based on a parameter or even on the data, but 99 times out 100 people use dynamic queries where they are not needed.
    Perhaps explain to us what you are really trying to achieve and why, and we could suggest some better way.

  • I need to divide selected row into multiple rows when i navigate  ADF 11g

    Hi
    I'm using jdeveloper 11.1.1.2.0 with ADF 11g.
    I need to divide selected row into multiple rows when i navigate to other page . Scenario - in first page i'm displaying some records with columns like empno , empstatus , empworkdepts ,curdepts
    Here empworkdepts gives the numeric number like no of departments work shifts 3 or 4 or 5. when i select any particular employee and fire next button to navigate next page.I have to divide the selected employee with same information into multiple times based on the empworkdepts value.
    empno empstatus empworkdepts curdept
    001 eds 2 TS
    002 hr 1 FO
    003 eds 4 TS
    *004 eds 3 TS*
    now i selected employee 004 , when i navigate to next page.
    Empno EmpStatus EmpWorkDepts CurDept
    004 eds 3 TS
    004 eds 3 TS
    004 eds 3 TS
    i did with java code in bean .but not stable .
    any help............
    thanks advance.............
    Edited by: user9010551 on May 5, 2010 10:48 PM
    Edited by: user9010551 on May 10, 2010 11:31 PM

    user9086775 wrote:
    Hi Experts,
    I have a requirment where i need to fetch parts of a single row into multiple rows from a singlt Query, i am sure it is possible using Pivots but just cant figure out an approach. Any help on this is highly appriciapted.
    Requirment:
    This is a sample set record in a table
    Product     Sub Product          Name    Age
    New Car    Nissan                   Tom        49
    New Car    Nissan                   Jack         36
    Old Car      Audi                     Sam         24
    Old Car      Jaguar                  Pint          26
    Old Car      Audi                     Smith       41
    I need to be able to fetch the above data in the below fashion
    Product     Sub Product          Name    Age
    New Car
    Nissan
    Tom        49
    Jack        36
    Old Car     
    Audi            
    Sam        24
    Smith      41
    Jaguar                   Pint         26Please help with ideas as to how can i achive the above without using PLSQL.
    Thanks in advance!You should be doing this in the client on not in the DB. Use the reporting tool that you use to do this.
    For example if you are in SQL Plus you can use the BREAK command.

  • Urgent: How to break 1 Row into Multiple Rows

    Hi Experts,
    I have a requirment where i need to fetch parts of a single row into multiple rows from a singlt Query, i am sure it is possible using Pivots but just cant figure out an approach. Any help on this is highly appriciapted.
    Requirment:
    This is a sample set record in a table
    Product Sub Product Name Age
    New Car Nissan Tom 49
    New Car Nissan Jack 36
    Old Car Audi Sam 24
    Old Car Jaguar Pint 26
    Old Car Audi Smith 41
    I need to be able to fetch the above data in the below fashion
    Product Sub Product Name Age
    New Car
    Nissan
    Tom 49
    Jack 36
    Old Car
    Audi
    Sam 24
    Smith 41
    Jaguar Pint 26
    Please help with ideas as to how can i achive the above without using PLSQL.
    Thanks in advance!

    user9086775 wrote:
    Hi Experts,
    I have a requirment where i need to fetch parts of a single row into multiple rows from a singlt Query, i am sure it is possible using Pivots but just cant figure out an approach. Any help on this is highly appriciapted.
    Requirment:
    This is a sample set record in a table
    Product     Sub Product          Name    Age
    New Car    Nissan                   Tom        49
    New Car    Nissan                   Jack         36
    Old Car      Audi                     Sam         24
    Old Car      Jaguar                  Pint          26
    Old Car      Audi                     Smith       41
    I need to be able to fetch the above data in the below fashion
    Product     Sub Product          Name    Age
    New Car
    Nissan
    Tom        49
    Jack        36
    Old Car     
    Audi            
    Sam        24
    Smith      41
    Jaguar                   Pint         26Please help with ideas as to how can i achive the above without using PLSQL.
    Thanks in advance!You should be doing this in the client on not in the DB. Use the reporting tool that you use to do this.
    For example if you are in SQL Plus you can use the BREAK command.

  • Convert one row to multiple column dynamic in smartform

    i want to convert on row to multiple column in smartform.As number of column is not per define..Please suggest the way out in smartform

    I saw a post and working perfect. The link is given below.
    http://scn.sap.com/community/abap/blog/2013/10/06/the-case-of-dynamic-columns-in-smartform
    Thanks to Eitan.

Maybe you are looking for