Combine rows?

I'm trying to combine two rows under one column.
using: oracle 10g
Here is my code
select
    cr.report_id as report_id,
    cr.report_name as report_name,
    ei.info as info
from SPSS.WEB_CLIENT_REPORTS_NFL CR,  spss.web_report_extra_info_nfl EI
where cr.report_id = ei.report_idcurrent output
report_id /  report_name    / info
11111        player scored      When a individual croses    
11111        player scored      the opponents end zonewhat i want the output to be
report_id /  report_name    / info
11111        player scored      When a individual croses the opponents end zone   Thanks

user652714 wrote:
is there another way of doing what i explained above...with something like a sum(to_char... ?
Edited by: user652714 on Nov 25, 2008 10:44 AMWouldn't that be nice, but no the SUM aggregate function doesn't operate on string data types. If you want to do something like SUM, you will need to create your own custom aggregate function. See the AskTom article cited earlier.
Do you have any column in your data that indicates the order in which your info column should be aggregated? if not you may get your phrases out of sequence and possibly generate a whole bunch of nonsense.

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

  • 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

  • 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 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?

    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;

  • Combining rows with comma delimited

    Hi All,
    I have two tables
    Table A
    ID Location ID
    1 6
    2 7
    1 9
    2 10
    3 7
    1 8
    2 9
    Table B
    ID
    1
    2
    3
    49
    8
    6
    I have to come up with something like this for each ID in table B, I have to write a query to get
    ID Location ID
    1 6, 9, 8
    2 7, 10, 9
    so for each Id I need to grab there Location Id and concatenate them with comma.
    How can I acheive this. Is it possible to avoid loops in this case?
    Anye help will be apprecaited.

    with a as (
               select 1 id,6 location_id from dual union all
               select 2,7 from dual union all
               select 1,9 from dual union all
               select 2,10 from dual union all
               select 3,7 from dual union all
               select 1,8 from dual union all
               select 2,9 from dual
         b as (
               select 1 id from dual union all
               select 2 from dual union all
               select 3 from dual union all
               select 49 from dual union all
               select 8 from dual union all
               select 6 from dual
    -- end of on-the-fly data sample
    select  id,
            rtrim(xmlagg(xmlelement(e,location_id,',').extract('//text()') order by rn),',') location_id_list
      from  (
             select  a.id,
                     a.location_id,
                     row_number() over(partition by a.id order by a.location_id) rn
               from  a,
                     b
               where b.id = a.id
      group by id
            ID LOCATION_ID_LIST
             1 6,8,9
             2 7,9,10
             3 7
    3 rows selected.
    SQL> SY.

  • Combining rows to remove blank entries

    Hi,
    I have searched the forum to try and find an example of the problem I am having but
    have not had any luck finding anything. Some help would be appreciated.
    I am currently using Oracle 9i.
    The problem is that I have a query, returning results as shown below
    and I want to remove as many null values as possible.
    Goals , Team1 , Team2
    1 , Jim , NULL
    1 , John , NULL
    1 , NULL , Bob
    2 , Harry , NULL
    2 , NULL , Steve
    3 , Jill ,NULL
    3 , NULL , Penny
    3 , NULL , Sally
    The Goals column is numeric, is not unique and is always filled.
    The Team1 column contains a name or is null.
    The Team2 column contains a name or is null.
    Either Team1 has a non null value or Team2 has a non null value.
    They cannot both be filled or both be blank.
    The result set I would like is an order on Goals, where we collapse the results as much as possible.
    So that if a non null Team1 row and Team2 row exist for a given number of goals, they are shown on the same row.
    We repeat this till all results are shown for a given number of goals.
    If there are more results in Team1 than Team2 say for a given goals scored, we show the team1 result and null for team2 and vice versa.
    If the Team1 and Team2 values can be sorted on name within the same goals scored, this would be great as well
    To visualise this, the table would look like: -
    Goals , Team1 , Team2
    1 , Jim , Bob
    1 , John , NULL
    2 , Harry , Steve
    3 , Jill , Penny
    3 , NULL , Sally
    Thanks for the help,
    Rich

    Here's an approach.
    ME_XE?with
      2     data as
      3  (
      4     select 1 as goals , 'Jim' as team1 , NULL as team2 from dual union all
      5     select 1 as goals , 'John' as team1 , NULL as team2 from dual union all
      6     select 1 as goals , NULL as team1 , 'Bob' as team2 from dual union all
      7     select 2 as goals , 'Harry' as team1 , NULL as team2 from dual union all
      8     select 2 as goals , NULL as team1 , 'Steve' as team2 from dual union all
      9     select 3 as goals , 'Jill' as team1 ,NULL as team2 from dual union all
    10     select 3 as goals , NULL as team1 , 'Penny' as team2 from dual union all
    11     select 3 as goals , NULL as team1 , 'Sally' as team2 from dual
    12  ),
    13     set_one as
    14  (
    15     select goals, team1, row_number() over (partition by goals order by team1 asc) as rn
    16     from data
    17     where team1 is not null
    18     order by team1 asc
    19  ),
    20     set_two as
    21  (
    22     select goals, team2, row_number() over (partition by goals order by team2 asc) as rn
    23     from data
    24     where team2 is not null
    25     order by team2 asc
    26  )
    27  select NVL(s1.goals, s2.goals), team1, team2
    28  from set_one s1 FULL OUTER JOIN set_two s2
    29  ON (s1.goals = s2.goals and   s1.rn = s2.rn)
    30  order by s1.goals asc
    31  /
    NVL(S1.GOALS,S2.GOALS) TEAM1           TEAM2
                         1 Jim             Bob
                         1 John
                         2 Harry           Steve
                         3 Jill            Penny
                         3                 Sally
    5 rows selected.

  • Combine rows of same value in to one row in sharepoint

    I have a list with three columns and I have the same set of values in all the three rows.
    column1  column2    total
    a              a             1
    a              a             1
    a              a             1
    I would like to concatenate and display this as the following in SharePoint 2010 list
    column1  column2    total
    a              a            3
    how to create this functionality in SharePoint 2010?

    Hi,
    Have you consider of making use of SharePoint Designer workflow?
    Assuming the situation is almost as you described in original post, we could set the condition as If value equals value, then update list item. As I tested in my environment, here are some suggestions:
    Set the workflow start automatically when item is created but not changed. If it starts when the item is changed, it will run one more time since the original item is to be updated.
    When we sum the value in total column, we could use intermediate variable, then do calculation, then update list item.
    At the end of the workflow, delete the current item.
    Regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected] .
    Rebecca Tu
    TechNet Community Support

  • Combine rows to one

    Hi Guys,
    Need to achive the following...
    SERIAL_NO
    PART_NO
    VEHICLE_ID
    171C
    M-8
    171C
    M-1
    593
    Here I need to merge the two rows to one using the following column headers...
    Serial_No Part_No1 Part_No2 Vehicle_ID
    Here Part_No1 should have the record value where Vehicle_ID is Null
    Thanks,
    Napster

    Try this.
    WITH tab(SERIAL_N, PART_NO, VEHICLE_ID) AS
    (SELECT '171C', 'M-8', NULL FROM dual UNION ALL
    SELECT '171C', 'M-1', 593  FROM dual UNION ALL
    SELECT '171D', 'M-9', NULL FROM dual UNION ALL
    SELECT '171D', 'M-2', 765 FROM dual)
    SELECT SERIAL_N,
            MIN(decode(VEHICLE_ID, NULL, part_no, NULL)) part_no_1,
            MIN(decode(VEHICLE_ID, NULL, NULL, part_no)) part_no_2,
            MIN(VEHICLE_ID)
    FROM tab
      group by SERIAL_N ;
    Only condition is that there are two records for each serial_id and one having null vehicle_id, other wise it may give wrong output.

  • 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

  • Combine rows and Sum

    I am using Oracle 10g.
    I have data as follows.
    ITEM|ITEMTYPE|QTY
    1|A|10
    1|B|15
    2|C|20
    2|D|25
    3|E|30
    3|F|30
    Output Should be as follows.
    ITEM|ITEMTYPE|QTY
    1|A-B|25
    2|C-D|45
    3|E-F|60
    Whether it could be possible through "Start with Connect by"
    Please help on it.

    You would have to present your case (at least) as
    ITEM|ITEMTYPE|QTY
    1|A|10
    1|B|15
    1|Q|25
    1|R|35
    1|Z|45
    2|C|20
    2|D|25
    3|E|30
    3|F|30
    3|G|30
    4|X|10
    ITEM|ITEMTYPE|QTY
    1|A-B-Q-R-Z|130
    2|C-D|45
    3|E-F-G|90
    4|X|10
    in the first place ;) and I might not (even now) got it right
    I cannot provide a tested solution as I don't have database access
    Regards
    Etbin
    Edited by: Etbin on 15.1.2011 12:31
    should look something like:
    select item,substr(sys_connect_by_path(itemtype,'-'),2) itemtype,qty
      from (select item,itemtype,sum(qty) over (partition by item order by itemtype) qty,
                   row_number() over (partition by item order by itemtype) n
              from your_table
    where connect_by_isleaf = 1
    start with n = 1
    connect by n = prior n + 1
            and item = prior item

  • Merging multiple rows in to a single row (when rows meet merging criteria)

    Hi 
    I have a scenario to merge multiple rows in to a single rows when the data in those rows fall in merge criteria .Below is how my data is 
    Now the merging logic for the above rows is , we need to combine multiple rows in to a single row when the data in those rows permits us to do in that way. Simply saying , its like sandwich where we combine multiple things to a single piece.The output for
    the above rows should be
    Here  we combined Row 1 ,2, 3 in to a single row as the data in those rows permits to merge in to single row. But the row 4 cannot be combined to any of those rows because the data in those rows doesn't permits us do a merge ( As the value of the column
    JobSource for the row 4 is different from the other rows ) .
    My original data has 56 columns , but for readability i kept only 9 columns. 
    can you please throw some idea on how to achieve this scenario. I know we need to use CTE for achieving this, but i am not able succeed in doing an iteration on multiple rows.
    Appreciate your response .

    Thanks for your reply .
    Rule for merging is simple . First of all there is no unique row identifier for each row , the fact table is not having an identity column in the database . I called row 1 , row 2  etc in my post above only to make better explanation of my scenario.
    The rule for merge is below. 
    1) we can combine only when the data in a column for one row is null & the data in same column for the other row is not null . It should also satisfy the condition where the data in other columns should conflict each other.
    2) Data for all columns for the merging rows should not be conflicting (i.e. we should not merge the rows when the data in a column is not equal to the same column in the other row
    ,considering not null value)
    Steps in merging the above source data :
    1) Consider the case of row 1 and row 2 in the source, we can combine these rows as the data is satisfying the rule 1 for columns (Jobsource,Flight, Package,Update,Iscancelled
    ,Result, Severity) and columns (JobID and RuleName ) fall under rule 2.  we merge these two rows in to a single row and keep in that in the table.
    2) Then the resulting row is again merged with the second row which is present above by applying the rule 1 and rule 2 . Below would be output of merge operation.
    Now there would be only two rows in the output . But these rows cannot be merged as the data doesn't satisfy the merge rules 2 . As Jobsource for the row 1 in the above output is "PresubmissionSource" which is not equal
    to "PostSubmission" jobSource which is in row 2. So these two rows are left unmerged .So the above two rows would be the output of merge operation on my source data.
    This process has to be repeated for all the rows in the table. As of now my table as 92 Million rows with 56 columns which need to be considered for merging rows. I replicated my scenario in 9 columns and 4 rows to understand better.

  • Reg:Arrangement of rows in UI table as our requirement....

    Hi all,
    In my Project I have an UI Table in which it is having 5 rows in that i have a column having Dropdown by keys and it will hold 5 possible values (Ex:Coverage type1,coverage type2.......coverage type5) and in which we will select two rows.
    wenever we are pressing combine Button (Action) those two values will combine to geather and should come in one row i.e (After Pressing combine Coverage type1 & Coverage type2,Cverage type3.........coverage type5 in one Drop Down in one row).
    iam able to do this the problem i have to solve is When ever iam combing two rows the combined two rows are coming at the last row but my wish is to get is:
    Ex: If i Combine 1st row and 2 row those combined row should come at first.
           if i Combine 2nd row and 1st row those combined row should come at Second.
            if i combine 3rd row and 4th row those combined row should come at third.
    like this it should hapeen so any one help me out in solving this issue.

    Ha Mahesh,
    Option 1: After removing your old rows (which I guess you do) and adding your new row, you could do a sort
    //You need to create a Comprator yourself implementing a Comparator Interface.
    Comparator cmp = new MySorter();
    wdContext.getNodeBlahBlah.sortElements(cmp)
    Option 2: After removing your old rows you can add your row and at the position you like.
    int index = 2;
    IWDNodeElement nodeElement = wdContext.createElement();
    wdContext.getNodeBlahBlah.addElement(index, nodeElement);
    Something like that ...
    Jeschael

  • Formula for cross tab row

    Post Author: bvandyck
    CA Forum: Formula
    The results of a row in a cross tab report need to be split out by percentages and added to the results of other rows.  Each row is an individual, except one row is a combination of individuals.  Certain individuals share in the results of the combination row.   The combination row will be zero after being added to the individuals' rows.  What is the formula for achieving this?

    Hi,
    U may create a new formula for that.
    There is an option in cross tab expert for new formula.
    U may create a formula of your choice and then insert in report.
    Regards,
    Misra P.

Maybe you are looking for

  • New to Apple world, 2G/3G/Lte working in ios8 (in India for all networks)

    Hi guys..... I am a great gadget lover, I have been using android and smart phones but now I am new to Apple. I possessed an Iphone 5C 16 GB on 24th Oct. I am here to clarify with a good news for the people of India regarding 2G/3G/Lte toggle, especi

  • Recording Videos

    I am having trouble recording video from really anything (tv, dvd player, vcr, etc). I have a friend who is using a MAC and a box called a Miglia Director's cut (http://www.miglia.com/products/video/director2/) all he does is hook up the director's c

  • Is there a way to recover a deleted app that was backed up on the iCloud but is no longer available on the App Store?

    I had downloaded this app before it was removed from the App store but I accidentally deleted it off my phone. It says it's back up with iCloud but I don't know how to get it back onto my phone. Is that even possible?

  • Very Extensive Gunner Z game data deleted? Included In-App purchases

    My IOS game app, Gunner Z by Bitmonster, is no longer able to retrieve my very extensive saved game data which included literally over a year of play and several In-App purchases. This disappearance of my data did not follow any update to the game it

  • Error in upgradation

    hi.. I am upgrading the database 11.1.0.7 version to 11.2.0.1 version. I am gettin the error msg like dis. "there is an error while creating the following process , $ORACLE_HOME/bin/sqlplus -S /NOLOG".I am using linux os 5 redhat. Edited by: 845224 o