How to combine rows?

This is probably a basic question, but I am rather new to this, so please bear with me. I have a table that contains a field for comments, and the comments are broken into chunks, something like this:
COMMENT_TABLE:
ID DIA_ID SEQ TEXT
== ====== === ====
01 000100 0 First part of comment.
02 000100 1 Second part of comment.
03 000101 0 Next comment, part 1.
04 000101 1 Next comment, part 2.
05 000101 2 Next comment, part 3.
06 000102 0 Another comment.
07 000103 0 Still another comment.
I would like to be able to run SQL against this table to combine the comments and end up with something like this:
DIA_ID TEXT
====== ====
000100 First part of comment. Second part of comment.
000101 Next comment, part 1. Next comment, part 2. Next comment, part 3.
000102 Another comment.
000103 Still another comment.
Is this possible, and if so, could someone give me an example of how to specify the SQL to do this?
Thanks very much!

Try this
select count(*),
trim(substr(max(substr(sys_connect_by_path (p.TEXT,','),2)),1,100)) as c2,
p.DIA_ID
from (select DIA_ID,
TEXT,
row_number() over (partition by DIA_ID order by DIA_ID, TEXT) rn
from table1) p
start with p.rn = 1
connect by p.rn = prior p.rn + 1
and prior p.DIA_ID = p.DIA_ID
group by DIA_ID
order by count(*) desc;

Similar Messages

  • How to combine rows with small numbers into single "other" row?

    How can I combine rows with value 6(for example) or lower to single row representing the SUM of all this values and label OTHER, so the pie chart will have a chance to display all small values combined?
    I'm using Numbers 09

    HI Peter,
    When you write a decimal number, is the decimal separator a period ( . ) or a comma ( , )? If it's a comma, then the syntax error can be corrected by replacing the list separator in the formula, a comma in Jerry's formula, with a semi colon ( ; ):
    =SUMIF(B; "<6"; B)
    (Added): The two Bs appear in blue 'lozenges' in Jerry's image because that is the way cell (or column) references are displayed in Numbers when a formula has correct syntax.
    Regards,
    Barry
    Message was edited by: Barry

  • How to combine Row members in Create Composit Forms in Planning 9301

    Hi All,
    I'm working on Hyperion System9 Planning 9.3.01. I have created two data forms for Actuals and Budget data. Wherein in Actuals form the actual data is pulled from the Oracle GL and I'm entering the budget data in my Budget Form.
    Now the question here is I wanted to combine these tow forms into a single form using "CreateComposite" option and I'm able to create the composite form for both actual and Budget form. But the composite form displays two separate forms side-by-side. Whereas I wanted to combine the Row members of both forms as both have same row members.
    Any help will be highly appreciated.

    Hi sajid
    There was nothing more description about your issue in this site and I found an issue below is mostly like yours
    http://www.codeproject.com/Questions/855487/how-to-combine-two-table-value-in-rdlc-report
    In the issue above, if you want to show the two other tables in the report, I think you could combine the tables into one datatable joining on key. The link below show an example of a DataSet Helper from Microsoft about combine DataSets. Take note of
    the related content for other DataSet Helper examples. And then you could use the datatable in your RDLC.
    # HOW TO: Implement a DataSet JOIN helper class in Visual C# .NET
    http://support.microsoft.com/kb/326080/en-us
    In an alternative way, I think you could create a view in the database which combine your tables and use it in your rdlc.
    In addition, your issue is about asp.net and you could get more support in the asp.net forum whose link as below.
    http://forums.asp.net
    Best Regards
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • How to combine rows from different unrelated tables?

    I need to create a report where the data are coming from 2 unrelated tables.  My calculation needs data from both tables.  Is this possible within Crystal Reports without having to write complicated SQL commands?  If not, can someone provide an example of such a query?
    thanks in advance
    -Mark

    Morning Mark,
    Yes Amr is right however there has to be  some sort of link between the two tables to create a join. For example a Order no from one table matches with other Order no.
    There could be another possibility and that is if you have a third table which has two fields common to those two tables then when you bring the third table it will act as a middle man.
    If you need to bring the information onto the report according to some sort of criteria then those two tables need to be linked togeather at some point otherwise it won't work.
    For example
    I have two tables, FOC and Customer, both have nothing in common however the third table Orders has fields which is common to FOC and Customer. So I linked the two tables via Orders table. Now when I open my report my results are based on the Customer and FOC number.
    Hope this helps
    Regards
    Jehanzeb

  • How to combine many rows into one row

    Hi all,
    I have a question regarding to how to combine many rows into one row?
    My result set is like that:
    ITEM_NO NAME1
    11 abc
    11 cde
    11 fg
    Want to combine them into
    ITEM_NO NAME1
    11 abc;cde;fg
    would anybody can tell me how to do that? Thanks
    Ray

    You can check this --
    satyaki>
    satyaki>
    satyaki>create table t
      2  as
      3      select 11 ITEM_NO, 'abc' NAME1 from dual
      4      union all
      5      select 11 ITEM_NO, 'cde' NAME1 from dual
      6      union all
      7      select 11 ITEM_NO, 'fg' NAME1 from dual;
    Table created.
    satyaki>
    satyaki>
    satyaki>
    satyaki>set lin 10
    satyaki>
    satyaki>desc t;
    Name              Null?    Type
    ITEM_NO                    NUMBER
    NAME1                      VARCHAR2(3)
    satyaki>
    satyaki>
    satyaki>set lin 1000
    satyaki>
    satyaki>
    satyaki>
    satyaki>SELECT ITEM_NO,
      2         LTRIM(MAX(SYS_CONNECT_BY_PATH(NAME1,';'))
      3         KEEP (DENSE_RANK LAST ORDER BY curr),';') AS NAME1_DET
      4  FROM   (SELECT ITEM_NO,
      5                 NAME1,
      6                 ROW_NUMBER() OVER (PARTITION BY ITEM_NO ORDER BY NAME1) AS curr,
      7                 ROW_NUMBER() OVER (PARTITION BY ITEM_NO ORDER BY NAME1) -1 AS prev
      8          FROM   t)
      9  GROUP BY ITEM_NO
    10  CONNECT BY prev = PRIOR curr AND ITEM_NO = PRIOR ITEM_NO
    11  START WITH curr = 1;
       ITEM_NO  NAME1_DET
            11  abc;cde;fgRegards.
    Satyaki De.

  • How to combine many rows into 1 rows in 1 column?

    Hi all,
    I have a question regarding to how to combine many rows into one row?
    My result set is like that:
    ITEM_NO NAME1
    11 abc
    11 cde
    11 fg
    Want to combine them into
    ITEM_NO NAME1
    11 abc;cde;fg
    would anybody can tell me how to do that? Thanks
    Ray

    Hi,
    select * from x2;
    INO NAME
    13 PQR
    11 ABC
    11 DEF
    12 JKL
    12 MNO
    11 GHI
    select p.ino as ITEMNO,
           substr(max(substr(sys_connect_by_path (p.name,';'),2)),1,60) as ITEMNAME
    from (select ino,name,
          row_number()over (partition by ino order by ino, name) rn
    from x2) p
    start with p.rn = 1
    connect by p.rn = prior p.rn + 1
    and prior p.ino = p.ino
    group by ino;
    OP
    ITEMNO ITEMNAME
    11 ABC;DEF;GHI
    12 JKL;MNO
    13 PQR cheers
    Nirmal

  • How to combine two datarows (business component data) in BI Publisher

    Hi ,
    We are using BI Publisher in Siebel Environment.
    We have data coming from two business components (like from 2 diff tables)
    a) <?for-each:ssTest1?>
    b) <?for-each:ssTest2?>
    ssTest1 and ssTest2 are the business components
    We need to combine these 2 datarows (a&b) and show the data into a single combined data row for ex like <?for-each:ssTest1ssTest2?> and show all the fields in that.
    I'm not sure how we can combine these two data rows into a single combined data row and show the data.
    Any help from any one would be apprecated.
    Thanks
    PV
    Edited by: user8633002 on Oct 21, 2010 4:05 PM

    Hi sajid
    There was nothing more description about your issue in this site and I found an issue below is mostly like yours
    http://www.codeproject.com/Questions/855487/how-to-combine-two-table-value-in-rdlc-report
    In the issue above, if you want to show the two other tables in the report, I think you could combine the tables into one datatable joining on key. The link below show an example of a DataSet Helper from Microsoft about combine DataSets. Take note of
    the related content for other DataSet Helper examples. And then you could use the datatable in your RDLC.
    # HOW TO: Implement a DataSet JOIN helper class in Visual C# .NET
    http://support.microsoft.com/kb/326080/en-us
    In an alternative way, I think you could create a view in the database which combine your tables and use it in your rdlc.
    In addition, your issue is about asp.net and you could get more support in the asp.net forum whose link as below.
    http://forums.asp.net
    Best Regards
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • How to combine more than 2  templates in same window horizontally

    Hello friends........
    can u tell me how to combine templates and windows in smart forms.
    Any example program to illustrate  it.
    I  am having a requirement that to  make a template by combining 3 windows which are having 3 templates by using the
    concept combining  templates and windows.
    i know folder concept but it will combine the nodes which are appended to  it ,but i don't what that one.....
    i want in a template with  2 windows with 2 templates coming  in  a same line .
    friends can u please help me out .......

    thank  u  very much for replying
    i have requirement in smart forms like this my client wants  a smart form in which i have to use the concept of
    combining 2 windows  inside a template
    actually some part of my template looks like this
    |-- | |--
    |
             vv
    this box should not have any rows in it, it should  be as it is like this plain.
    when i have searched the net i found that this can be done by the concept of combining templates and windows we can do it.
    i went to sap portal and  read sap press eBook and seen many sites but i could not
    find the way to do this .
    can u please guide me what  can i do.....

  • Question related to combining rows...

    Hi,
    I have a question related to combining rows...
    From our typical tables.... Dept and Emp.
    I want a result set like....
    Dept# | Employees
    10 | <Emp1>, <Emp5>, <Emp6>
    20 | <Emp7>, <Emp2>, <Emp8>, <Emp9>
    30 | <Emp10>, <Emp11>
    40 | <Emp12>
    Plesae give me the query...
    Thanks
    Abdul.

    How about this solution looks like?
    create or replace
    function fnc_concat_data(p_query VARCHAR2,P_ID NUMBER) RETURN VARCHAR2
    AS
    type res_tab is table of varchar2(20);
    result_tab res_tab;
    v_retval varchar2(256);
    begin
    execute immediate p_query || p_id BULK COLLECT into result_tab;
    FOR i IN 1..result_tab.COUNT LOOP
    v_retval := v_retval||','||result_tab(i);
    END LOOP;
    v_retval := substr(v_retval,2);
    return (v_retval);
    exception
    when others then
    return('Error');
    end fnc_concat_data;
    sql> select deptno, fnc_concat_data('select ename from emp where deptno=', deptno) employees from emp group by deptno
    deptno employees
    30     ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
    20     SMITH,JONES,SCOTT,ADAMS,FORD
    10     CLARK,KING,MILLER

  • How to combine Tables GLPCA & GLPCP

    Hi All,
    I have a requirement to show Actual and Plan values for Material and GL Accounts in a Report.
    The Actual values come from GLPCA table and the Plan values come from GLPCP table. But the problem is that the GLPCP table continas the values on period basis.
    Could you please help me find a solution on how to combine data from these 2 tables and display in the report.

    Hi Sandeep
    We had the same scenario in our project too. Our approach was - We create two independant DSOs, one for holding data from GLPCA and another from GLPCP. Please note GLPCA will contain data at the lowest denomination meaning at the day level, whereas GLPCP will contain at the period level. In order to achieve reporting from both we created a multiprovider where fiscal period from both the DSO's was included in the multiprovider (do not include calendar day) so that when you report GLPCA data will be aggregated at the period level and GLPCP data already at the period level will both be shown in a single row with common characteristics like Profitcenter, material, Customer etc.
    I hope this helps.
    Thanks.

  • Combine rows based on column value

    I'm trying to combine rows based off of a common value.
    Table Data:
    Result A
    Player_ID   Player_Name  Team_Name  Points Sequence
    99999       John Smith    Bulls              50         1
    99999       John Smith    Pistons          14         2
    What i want in the output
    Result B
    Player_ID Player_Name Team_Name  Points
    99999     John Smith      Bulls           64 (50 for Bulls)Here's my main query...
    select player_id, player_name, team_name, points
    from
              SELECT player_id, player_name, team_name, sum(points) sum_points
              FROM stats_data
              WHERE season_id = 2008
              AND points > 0
              GROUP BY player_id, player_name, team_name
              ) t
    ORDER BY sum_points DESC, last_name;**The current query gives me the output from Result A
    1) Not entirely sure how to combine data based of player_id
    2) Once i figure out 1, im sure by adding the ('sum_points' for 'team_name') to the output can be done with a case statement, i think?

    Sorry about that Frank.
    Using: Oracle 10.2g
    i was incorrect about the output of the query
              SELECT player_id, sum(points) sum_points
              FROM stats_data
              WHERE season_id = 2008
              AND points > 0
              GROUP BY player_id
    )Output
    Player_ID      Sum_Points    
    99999              20        
    55455               6          
    66489               2  So the subquery is outputing the correct data
    The output of the original entire query(that you had posted) is:
    Player_ID    Player_Name   Team_Name    Points    
    99999        John Smith      Bulls               16 (8 for  Bulls)    
    55455        Bob Johnson    Rockets          6   (3 for Rockets)
    66489        Chris Terry       Kings              2   (1 Kings)Here's some more raw sample data from the table:
    Player_ID    Player_Name   Team_Name    Points     Sequence  Game_Type_ID Team_ID
    99999        John Smith      Bulls               12          1                       1                  5
    99999        John Smith      Bulls               0            1                      -1                  5
    99999        John Smith      Pistons            4           2                       1                 12
    99999        John Smith      Pistons            0           2                       -1                12
    55455        Bob Johnson    Rockets          4           1                        1                  3 
    55455        Bob Johnson    Rockets          0           1                       -1                  3 
    66489        Chris Terry       Kings              2           1                        1                  8
    66489        Chris Terry       Kings              0           1                       -1                  8So your code frank is very close, the issue is that:
    A) All players have a ('pt value' for 'team name') even if they played on the same team, which can prob. be solved with a case statement, which i tried to do in my last post.
    WITH       grouped_data     AS
              SELECT player_id, sum(points) sum_points
              FROM stats_data
              WHERE season_id = 2008
              AND points > 0
              GROUP BY player_id
    SELECT     g.player_id
    ,     s.player_name
    ,     s.team_name
    (case when sequence = 2 then g.sum_points  <==
         ||  '('
         ||  TO_CHAR (s.points)
         ||  ' for '
         ||  s.team_name
         || ')'
    else to_char (g.sum_points)
    END)     AS points
    FROM     grouped_data     g
    JOIN     stats_data     s     ON g.player_id     = s.player_id
    WHERE     s.sequence     in (1,2)     <==
    AND     s.season_id     = 2008
    AND     s.points     > 0;the output has two issues, for players who played on more than one team, like Josh Smith the output comes out as
    99999        John Smith      Pistons           20  (2 for Pistons)        
    99999        John Smith      Bulls               20While the players who played on one team came out correctly. So issue with my edit of your code is:
    A) josh smith is output 2, needs to be output once
    B)josh smith should say (Josh Smith Bulls 20 (4 for Pistons) not "99999 John Smith Pistons 20 (2 for Pistons)"
    c) Issues with "99999 John Smith Pistons 20 (2 for Pistons)" is that it listing the wrong team for him: should be Bulls and listing half of his total with the pistons in the prentices should be 4. --The reason that is because s.points needs to be summed as based off of the data there's two entries
    Hope this clears it up, thanks!
    Edited by: user652714 on Mar 11, 2009 9:28 AM

  • How to combine several measures into 1 pie chart

    Hello everyone,
    I have a requirement to create a design studio application with a pie chart to show several measures.
    It means that I have several different measures and I want to let each piece of the pie chart present 1 measure.
    For example, I need to combine measure1 ,measure2, measure3(which correspond KeyFigures in Bex query) into 1 pie chart and there should have 3 pieces.I tried change swap axis option and put all measures into row, not works.
    I am very appreciate if anyone could help. Thanks a lot.

    Hi !
    There is a tricky way to do that.
    Read the following document How to combine several measures into 1 Pie chart
    hope it helps,
    Roman

  • How to combine a one columns into 1?

    I am using Oracle 8i,
    I want to know that how to combine a one columns into 1 row:
    For example:
    ITEM_NO NAME
    01 ABC
    01 CDE
    Result Set:
    ITEM_NO NAME
    01 ABC; CDE
    I have try to use "SYS_CONNECT_BY_PATH" this function, however, that function can use in Oracle 9i or 10g, NOT 8i.
    So please please help me to solve that. Many thanks.

    Check this thread
    Re: column values separated by ,

  • Does anyone know how to combine two apple ID's together?

    I have found out that I have two Apple ID's! One is for my apps on my iphone and the other is for iTunes.  Somehow they are set to different email addresses but are being sent to the same email address.  Does anyone know how to combine them, so I use just one Apple ID?

    This is my solution too.
      You see, what I also downloaded all the free apps I have on iPhone to this account I choose to use, so this way I didn't need to change accounts (of course it was on the iOS 5 times)

  • How to get row number of selected entry from OVS search result

    Hi,
    Anyone having any idea on how to get row number of the  selected entry/ how to differentiate rows in OVS search result in ON_OVS method?
    Regards,
    Jatin

    Hi,
    You can get the selected record to <ls_selection> structure in co phase 3.
    From that structure you can get what ever field you want.,
    check the below code for reference,
    << Moderator message - Cut and paste response from F4 help for ALV table field removed. Plagiarism is not allowed in SCN >>
    hope this helps u.,
    Thanks & Regards,
    Kiran
    Edited by: Rob Burbank on Jan 5, 2012 5:24 PM

Maybe you are looking for